public bool Exchange (bool newVal) { int newTemp = newVal ? Set : UnSet; return AotInterlocked.Exchange (ref flag, newTemp) == Set; }
public void Exchange() { AtomicBoolean ai = new AtomicBoolean( true ); Assert.AreEqual(true, ai.Exchange(false)); Assert.AreEqual(false, ai.Exchange(false)); Assert.AreEqual(false, ai.Exchange(true)); Assert.AreEqual( true, ai.Value ); }