On 27/04/2013 09.05, Vicente J. Botet Escriba wrote:
The change set is https://svn.boost.org/trac/boost/changeset/84055. To see the sources, you would need to update the trunk or to take a look at https://svn.boost.org/svn/boost/trunk/boost/thread/
Please let me know what do you think.
Is the explicit lk.unlock() inside the bool count_down(unique_lock<mutex> &lk); needed ? I see the two places where it's called are: void count_down() { boost::unique_lockboost::mutex lk(mutex_); count_down(lk); } and void count_down_and_wait() { boost::unique_lockboost::mutex lk(mutex_); if (count_down(lk)) { return; } count_.cond_.wait(lk, detail::counter_is_zero(count_)); } in both cases the unique_lock does the job, or I'm missing something? Also I would add a new method to boost::detail::counter bool dec_and_notify_all_if_value(const std::size a_value) { if (--value_ == a_value) { cond_.notify_all(); return true; } return false; } This way you can further simplify the count_down(unique_lock<mutex> &lk) method: //lk is here only to assure it's a thread safe call bool count_down(unique_lock<mutex> &lk) /// pre_condition (count_.value_ > 0) { BOOST_ASSERT(count_.value_ > 0); return count_.dec_and_notify_all_if_value(0); } Regards Gaetano Mendola