C++ Logo

std-discussion

Advanced search

Re: Synchronization of atomic notify and wait

From: language.lawyer_at <language.lawyer_at_[hidden]>
Date: Tue, 19 Jul 2022 11:58:26 +0500
On 19/07/2022 11:43, Andrey Semashev via Std-Discussion wrote:
> It means the store happens-before notify_one (in the non-main thread).
>
> Coherence-ordered before is the relation between the store and the wait in the two threads.
> It says that when the store is coherence-ordered before the wait in the modification order of the atomic, the wait will observe the effects of the store.

To me, http://eel.is/c++draft/atomics.order#3 reads in the opposite direction. If the wake-up read observes the new value, it will become coherence-ordered before. But if it does not observe, it won't.
So, what guarantees it will observe the new value?

> And since the store happens-before the notify, if the wait is woken by the notify there is no way it doesn't observe the store.

Because?..

Received on 2022-07-19 06:58:33