Quantcast
Channel: Can a write to std::atomic go unseen by other threads while using std::atomic::compare_exchange_strong? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Paul Sanders for Can a write to std::atomic go unseen by other threads while using std::atomic::compare_exchange_strong?

$
0
0

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?


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>