Index: reverse_lock.hpp =================================================================== --- reverse_lock.hpp (revision 82281) +++ reverse_lock.hpp (working copy) @@ -30,12 +30,22 @@ } mtx=m.release(); } + + /** Re-take lock. Must be done before destruction. + Note that this cannot be done in the destructor, since locking might throw. */ + void lock() + { + if (mtx) { + mutex_type * mtx_tmp = mtx; + mtx = 0; // prevent destructor assert from also failing in the event of lock failure + mtx_tmp->lock(); + m = BOOST_THREAD_MAKE_RV_REF(Lock(*mtx_tmp, adopt_lock)); + } + } + ~reverse_lock() { - if (mtx) { - mtx->lock(); - m = BOOST_THREAD_MAKE_RV_REF(Lock(*mtx, adopt_lock)); - } + BOOST_VERIFY(mtx == 0); // check that lock has been explicitly called } private: