コード例 #1
0
 public void Execute(int i)
 {
     if (i % 2 > 0)
     {
         counter.TryIncrement(int.MaxValue);
     }
     else
     {
         counter.TryDecrement(int.MinValue);
     }
 }
コード例 #2
0
    public void NativeLimitedCounter_Allocate_Deallocate_Read_Write()
    {
        var c = new NativeLimitedCounter(Allocator.Persistent);

        int cnt = 0;

        for (var i = 0; i < 100; ++i)
        {
            c.TryIncrement(100 /* max */);
            ++cnt;
        }
        Assert.AreEqual(cnt, c.Count);

        c.Dispose();
    }
コード例 #3
0
    public void NativeLimitedCounter_IncrementDecrement()
    {
        const int MAX     = 1000;
        var       counter = new NativeLimitedCounter(Allocator.Persistent);

        for (var i = 0; i < MAX / 2; ++i)
        {
            counter.TryIncrement(MAX);
        }
        var job = new Job2();

        job.counter = counter;
        job.Schedule(MAX, 32).Complete();

        Assert.AreEqual(MAX / 2, counter.Count);
        counter.Dispose();
    }
コード例 #4
0
 public void Execute(int i)
 {
     counter.TryIncrement(maximum);
 }
コード例 #5
0
        public void Execute(int i)
        {
            bool success = counter.TryIncrement(maximum);

            Assert.IsTrue(success);
        }