public void AtomicIntegerArray_Store_Should_Fail() { var atomicIntegerArray = new AtomicIntegerArray(new [] { 100 }); Assert.Throws <InvalidOperationException>(() => atomicIntegerArray.Store(0, int.MinValue, MemoryOrder.Acquire)); #pragma warning disable 618 Assert.Throws <NotSupportedException>(() => atomicIntegerArray.Store(0, int.MinValue, MemoryOrder.Consume)); #pragma warning restore 618 }
public void AtomicIntegerArray_Store_Should_Success(int initialValue, int storeValue, MemoryOrder order) { var atomicIntegerArray = new AtomicIntegerArray(new int[] { initialValue }, MemoryOrder.Relaxed); atomicIntegerArray.Store(0, storeValue, order); Assert.Equal(storeValue, atomicIntegerArray[0]); }
public void AtomicIntegerArray_Store_MemoryOrder_Should_Success(MemoryOrder order) { var atomicIntegerArray = new AtomicIntegerArray(new int[3], order); for (int i = 0; i < atomicIntegerArray.Count; i++) { atomicIntegerArray.Store(i, i, order); } for (int i = 0; i < atomicIntegerArray.Count; i++) { Assert.Equal(i, atomicIntegerArray.Load(i, order)); } for (int i = 0; i < atomicIntegerArray.Count; i++) { atomicIntegerArray.Store(i, i, order); } for (int i = 0; i < atomicIntegerArray.Count; i++) { Assert.Equal(i, atomicIntegerArray.Load(i, order)); } }
public void AtomicIntegerArray_Load_Acquire_Should_Success(MemoryOrder order) { var atomicIntegerArray = new AtomicIntegerArray(new int[3], order); for (int i = 0; i < atomicIntegerArray.Count; i++) { Assert.Equal(0, atomicIntegerArray.Load(i, MemoryOrder.Acquire)); atomicIntegerArray.Store(i, i, MemoryOrder.Release); } for (int i = 0; i < atomicIntegerArray.Count; i++) { Assert.Equal(i, atomicIntegerArray.Load(i, MemoryOrder.Acquire)); } }
public void AtomicIntegerArray_Store_Should_Fail() { var atomicIntegerArray = new AtomicIntegerArray(new []{100}); Assert.Throws<InvalidOperationException>(() => atomicIntegerArray.Store(0, int.MinValue, MemoryOrder.Acquire)); #pragma warning disable 618 Assert.Throws<NotSupportedException>(() => atomicIntegerArray.Store(0, int.MinValue, MemoryOrder.Consume)); #pragma warning restore 618 }
public void AtomicIntegerArray_Store_Should_Success(int initialValue, int storeValue, MemoryOrder order) { var atomicIntegerArray = new AtomicIntegerArray(new int[] {initialValue}, MemoryOrder.Relaxed); atomicIntegerArray.Store(0, storeValue, order); Assert.Equal(storeValue, atomicIntegerArray[0]); }