id,summary,reporter,owner,description,type,status,milestone,component,version,severity,resolution,keywords,cc 12620,Make boost::unique_lock::unlock respect BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED,Alexandre Pereira Nunes ,viboes,"For a C++11 conformant g++ with working C++11 threads, the following code works if LIB is defined to std and throws if defined to boost:: {{{ #define LIB boost LIB::mutex mtx; LIB::unique_lock l(mtx, LIB::defer_lock); LIB::condition_variable cnd; cnd.wait(l, []{ /*whatever*/ return true;}); // this throws. }}} The attached patch makes boost::unique_lock::unlock respect BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED and not require the lock to be held (if you'll ever have only one thread waiting on a condition variable it seems that the mutex is useless as there's no race involved, c++11 threads at least when backed by pthread seems to follow that behavior). Even with this patch, boost *will* lock the mutex on exit - I didn't attempt to change that (as my code copes with that), but c++11 seems to avoid touching the mutex or correctly leaves it as it once was. I'm not sure what/if any of this behavior is standardized or implementation dependent, but it seems more coherent to respect BOOST_THREAD_THROW_IF_PRECONDITION_NOT_SATISFIED - specially the common case where it's not defined. ",Support Requests,closed,To Be Determined,thread,Boost 1.62.0,Not Applicable,worksforme,,