Quantcast
Channel: What is the use case for the atomic exchange (read-write) operation? - Stack Overflow
Browsing all 2 articles
Browse latest View live

Answer by Kerrek SB for What is the use case for the atomic exchange...

Your typical spinlock:std::atomic<bool> lock; // initialize to false{ // some critical section, trying to get the lock: while (lock.exchange(true)) { } // now we have the lock /* do stuff */ lock...

View Article



What is the use case for the atomic exchange (read-write) operation?

C++0x specifies the std::atomic template for thread safe atomic access to variables. This template has, among others, a member function std::atomic::exchange that atomically stores a new value in...

View Article
Browsing all 2 articles
Browse latest View live


Latest Images

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