Friday, March 4, 2011

A Tour of OSAtomic

Mike Ash:

To see how you can use these, let’s consider how you would write OSAtomicAdd32 using compare and swap. Again, it works using a transaction model. First, fetch the original value. Then add to obtain a new value. Finally, use compare and swap with the original and new values. If it failed, go back and try everything again.

Comments RSS · Twitter

Leave a Comment