C++ Logo

std-discussion

Advanced search

Re: Synchronization of atomic notify and wait

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 20 Jul 2022 07:24:58 -0700
On Wednesday, 20 July 2022 01:46:45 PDT language.lawyer--- via Std-Discussion
wrote:
> Ofc, the non-main thread could "publish" its L1 cache or the main thread
> could ask for update, but why do they have to do it, from the C++ abstract
> machine POV? What they violate if they don't do it?

You should understand the notify() as a non-value modification. As update of
the value happened-before the notification, then you must be able to see it too
if you see the notification. It's the same atomic, not some other value. An
update to an atomic is cumulative to all the previous updates to it.

An implementation that fails like you'd described in the previous paragraph
would be defective.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DPG Cloud Engineering

Received on 2022-07-20 14:25:01