コード例 #1
0
    public void NativeLimitedCounter_OverTheNumber()
    {
        const int MAX     = 1000;
        var       counter = new NativeLimitedCounter(Allocator.Persistent);
        var       job     = new Job1();

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

        Assert.AreEqual(MAX, counter.Count);
        counter.Dispose();
    }
コード例 #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();
    }