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 ArticleWhat 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