Quantcast
Channel: How to atomically perform sequential load and store operations? - Stack Overflow
Browsing index pages (3 articles)
↧

How to atomically perform sequential load and store operations?

Consider this code under GCC 4.8.0:std::atomic<bool> a;std::atomic<bool> b;a.store( b.load() ); // want to be atomicHow can I make the line above to be atomic as whole? In other words, how...

View Article


Answer by wilx for How to atomically perform sequential load and store...

I do not think that is possible. I do not think it is useful to have such operation. Why do you want it? If you have such hard requirement then you should just use std::mutex locked around a = b...

View Article


Answer by Krzysztof Narkowicz for How to atomically perform sequential load...

In theory atomic variable swap could be implemented on a few CPUs with DCAS support. In practice no modern CPU has DCAS support, so it's not possible.

View Article
Browsing index pages (3 articles)


Latest Images