Quantcast
Channel: Lockfree Read value after Interlocked.Exchange? - Stack Overflow
Browsing all 3 articles
Browse latest View live

Answer by Valery Petrov for Lockfree Read value after Interlocked.Exchange?

If you want to read the latest available value, you should use something like Interlocked.CompareExchange(ref bar, null, null). Checking for null is just for satisfying CompareExchange signature (if...

View Article



Answer by xanatos for Lockfree Read value after Interlocked.Exchange?

You are missing the point...Unless you do: public void OtherStuffFromThread2(){ while (true) { //how do I ensure that I have the latest bar ref here //considering mem cahces etc bar.Something(); }}That...

View Article

Lockfree Read value after Interlocked.Exchange?

Lets say we have a class like so:public class Foo{ private Bar bar = new Bar(); public void DoStuffInThread1() { var old = Interlocked.Exchange(ref bar,new Bar()); //do things with old //everything is...

View Article
Browsing all 3 articles
Browse latest View live


Latest Images