Boost C++ Libraries: Ticket #7319: Take care of c++std-lib-32966 issue https://svn.boost.org/trac10/ticket/7319 <p> Take care of the issue raised by Howard Hinnant in </p> <p> [c++std-lib-32966] Public service announcement concerning ~condition_variable_any() </p> <p> "Both condition_variable and condition_variable_any are based on the POSIX pthread_cond_t. One of the very subtle behaviors of pthread_cond_t is that it is ok for a pthread_cond_t to be destroyed after all waiting threads have been signaled (assuming no new threads initiate a wait). There's even an example demonstrating this at <a class="ext-link" href="http://www.unix.org/online.html"><span class="icon">​</span>http://www.unix.org/online.html</a> under the specification for pthread_cond_destroy. </p> <p> This subtlety is reflected in the Requires clause for the destructor of both condition_variable and condition_variable_any: </p> <blockquote class="citation"> <p> Requires: There shall be no thread blocked on *this. [Note: That is, all threads shall have been notified; they may subsequently block on the lock specified in the wait. This relaxes the usual rules, which would have required all wait calls to happen before destruction. Only the notification to unblock the wait must happen before destruction. The user must take care to ensure that no threads wait on *this once the destructor has been started, especially when the waiting threads are calling the wait functions in a loop or using the overloads of wait, wait_for, or wait_until that take a predicate. — end note ] </p> </blockquote> <p> To be *perfectly* clear, the following is ok: </p> <pre class="wiki"> Thread A Thread B ... lk.lock() ... cv.wait(lk) lk.lock() ... cv.notify_one() ... cv.~condition_variable_any() ... lk.unlock() ... ... finally exits cv.wait // ok, not a data race </pre><p> " </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7319 Trac 1.4.3 viboes Sun, 02 Sep 2012 08:41:34 GMT owner, status changed https://svn.boost.org/trac10/ticket/7319#comment:1 https://svn.boost.org/trac10/ticket/7319#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket