
14 May
2008
14 May
'08
4:50 a.m.
On 5/14/08, Peisheng Wang
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!