Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync primitives safe destruction #1481

Closed
K-ballo opened this issue Apr 27, 2015 · 1 comment · Fixed by #1488
Closed

Sync primitives safe destruction #1481

K-ballo opened this issue Apr 27, 2015 · 1 comment · Fixed by #1488

Comments

@K-ballo
Copy link
Member

K-ballo commented Apr 27, 2015

Synchronization primitives should guarantee that their destructors might run concurrently with a sync function. This is explicitly required for latch, and should be extended to all other primitives to support use cases like this. It should be sufficient to make sure that no code is executed after the sync operation (similarly to how a delete this would be handled)

@K-ballo
Copy link
Member Author

K-ballo commented May 7, 2015

std::condition_variable[_any] have special wording to this effect too:

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]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants