$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Christian Henning (chhenning_at_[hidden])
Date: 2005-07-29 11:43:20
Hi there, I'm converting over our codebase to make use of the boost
libs. Is there a way to manually lock and unlock a boost:mutex? Or, is
there a conditional lock available? I know there is
boost::mutex::scoped_lock that does it automatically.
Here is code example that, I think, requires manual locking:
void foo()
{
if( condition )
oMutex.lock;
do something
if( condition )
oMutex.unlock;
}
It might be that our code isn't designed very well for using boost::mutex.
One solution would be:
void foo()
{
if( condition )
{
boost::mutex::scoped oLock( oMutex );
do something
}
else
{
do something
}
}
Thanks,
Christian