// // Int32 // public static int CompareExchange(system.Int32 data, int update, int expect) { int current = data.VolatileGet(); data.CompareAndSwap(expect, update); return(current); }
public static int Exchange(system.Int32 data, int update) { for (;;) { int current = data.VolatileGet(); if (data.CompareAndSwap(current, update)) { return(current); } } }
public static int Add(system.Int32 data, int v) { for (;;) { int current = data.VolatileGet(); int next = current + v; if (data.CompareAndSwap(current, next)) { return(next); } } }
public static int Decrement(system.Int32 data) { for (;;) { int current = data.VolatileGet(); int next = current - 1; if (data.CompareAndSwap(current, next)) { return(next); } } }