Boost logo

Boost Users :

From: dhruva (dhruvakm_at_[hidden])
Date: 2008-05-14 00:50:52


On 5/14/08, Peisheng Wang <peisheng.wang_at_[hidden]> 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);
> }

The valriable 'lock' is created in the local scope and will get
destroyed once you are out of the 'if' scope. Also, use of macros for
things that do not change at runtime is better as it avoids the
runtime overhead of performing the check.

-dky

-- 
Contents reflect my personal views only!

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