So, to provide a definitive answer to this, no, a write from thread1 will never be missed by thread0.
This is because std::atomic::compare_exchange_strong
is an atomic operation so the write from thread0 either happens before this operation starts (in which case it returns false
) or after it completes (in which case the call will fail next time round the loop).
If it was any other way, compare_exchange_strong
would have no utility, no?