Skip to content

Conversation

@sergey-semenov
Copy link
Contributor

The flag that kills the threads waiting for work was an atomic bool, but that is not enough: any modification of a condition must be made under the mutex associated with that condition variable. Otherwise, the bool value flip and the call to notify might happen after the condition check in the other thread, but before it starts waiting for notifications.

The flag that kills the threads waiting for work was an atomic bool,
but that is not enough: any modification of a condition must be made
under the mutex associated with that condition variable. Otherwise,
the bool value flip and the call to notify might happen after the
condition check in the other thread, but before it starts waiting for
notifications.
Copy link
Contributor

@steffenlarsen steffenlarsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable. Should we consider using std::counting_semaphore when we switch to C++20 in the future?

@againull againull merged commit 8fc9aa5 into intel:sycl Sep 27, 2024
12 checks passed
AlexeySachkov pushed a commit to AlexeySachkov/llvm that referenced this pull request Nov 27, 2024
The flag that kills the threads waiting for work was an atomic bool, but
that is not enough: any modification of a condition must be made under
the mutex associated with that condition variable. Otherwise, the bool
value flip and the call to notify might happen after the condition check
in the other thread, but before it starts waiting for notifications.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants