Boost logo

Boost Users :

From: Nat Goodspeed (nat_at_[hidden])
Date: 2008-05-14 12:26:16


Peisheng Wang wrote:

> Why
>
> #if ISTHREADSAFE
> boost::mutex::scoped_lock lock(CacheInfo_mutex);
> # endif
>
> functions well , but not
>
> if(isThreadSafe)
> {
> boost::mutex::scoped_lock lock(CacheInfo_mutex);
> }

Because the scoped_lock declaration goes out of scope at the }. If you
had written:

#if ISTHREADSAFE
{
     boost::mutex::scoped_lock lock(CacheInfo_mutex);
}
# endif

it would have the same problem.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net