
14 May
2008
14 May
'08
10:26 a.m.
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.