public void GetSetCount() { var counter = new NativePerThreadCounter(Allocator.Temp); Assert.AreEqual(0, counter.Count); counter.Count = 42; Assert.AreEqual(42, counter.Count); counter.Count = 3; Assert.AreEqual(3, counter.Count); counter.Dispose(); }
public void ParallelIncrement() { var counter = new NativePerThreadCounter(Allocator.Temp); var jobData = new ParallelCountTo(); jobData.counter = counter; // Count every second item jobData.countMask = 1; jobData.Schedule(1000000, 1).Complete(); Assert.AreEqual(500000, counter.Count); counter.Dispose(); }
public void Increment() { var counter = new NativePerThreadCounter(Allocator.Temp); Assert.AreEqual(0, counter.Count); counter.Increment(); Assert.AreEqual(1, counter.Count); counter.Increment(); counter.Increment(); Assert.AreEqual(3, counter.Count); counter.Dispose(); }
public void SetCountConcurrentIncrement() { var counter = new NativePerThreadCounter(Allocator.Temp); NativePerThreadCounter.Concurrent concurrentCounter = counter; Assert.AreEqual(0, counter.Count); concurrentCounter.Increment(); Assert.AreEqual(1, counter.Count); counter.Count = 40; Assert.AreEqual(40, counter.Count); concurrentCounter.Increment(); concurrentCounter.Increment(); Assert.AreEqual(42, counter.Count); counter.Dispose(); }