Subject: [Boost-bugs] [Boost C++ Libraries] #7319: Take care of c++std-lib-32966 issue
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-09-02 08:32:23
#7319: Take care of c++std-lib-32966 issue
------------------------------+---------------------------------------------
Reporter: viboes | Owner: anthonyw
Type: Bugs | Status: new
Milestone: To Be Determined | Component: thread
Version: Boost 1.51.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------------------------
Take care of the issue raised by Howard Hinnant in
[c++std-lib-32966] Public service announcement concerning
~condition_variable_any()
"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
http://www.unix.org/online.html under the specification for
pthread_cond_destroy.
This subtlety is reflected in the Requires clause for the destructor of
both condition_variable and condition_variable_any:
> 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 ]
To be *perfectly* clear, the following is ok:
{{{
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
}}}
"
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7319> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:10 UTC