public void AtomicInt64SupportsGetAndAddMultiThreaded() { const long expected = 0; var i = new AtomicInt64(); i.GetAndSet(1000); System.Threading.Tasks.Parallel.For(0, 1000, j => i.GetAndAdd(-1)); Assert.AreEqual(expected, (long)i); Assert.AreEqual(expected, i.Value); }
public void AtomicInt64SupportsGetAndAddNegatives() { const long expected = 0; var i = new AtomicInt64(); i.GetAndSet(1000); for (int j = 0; j < 1000; j++) { i.GetAndAdd(-1); } Assert.AreEqual(expected, (long)i); Assert.AreEqual(expected, i.Value); }