Example #1
0
    public void ResizedListToDeferredJobArray([Values(0, 1, 2, 3, 4, 5, 6, 42, 97, 1023)] int length)
    {
        var list = new NativeList <int>(Allocator.TempJob);

        var setLengthJob = new SetListLengthJob {
            list = list, ResizeLength = length
        };
        var jobHandle = setLengthJob.Schedule();

        var setValuesJob = new SetArrayValuesJobParallel {
            array = list.AsDeferredJobArray()
        };

        setValuesJob.Schedule(list, 3, jobHandle).Complete();

        Assert.AreEqual(length, list.Length);
        for (int i = 0; i != list.Length; i++)
        {
            Assert.AreEqual(length, list[i]);
        }

        list.Dispose();
    }
Example #2
0
    public unsafe void DeferredParallelForFromIntPtr()
    {
        int length = 10;

        var lengthValue = new NativeArray <int>(1, Allocator.TempJob);

        lengthValue[0] = length;
        var array = new NativeArray <int>(length, Allocator.TempJob);

        var setValuesJob = new SetArrayValuesJobParallel {
            array = array
        };

        setValuesJob.Schedule((int *)lengthValue.GetUnsafePtr(), 3).Complete();

        for (int i = 0; i != array.Length; i++)
        {
            Assert.AreEqual(length, array[i]);
        }

        lengthValue.Dispose();
        array.Dispose();
    }
Example #3
0
    public void ResizeListBeforeSchedule([Values(5)] int length)
    {
        var list = new NativeList <int>(Allocator.TempJob);

        var setLengthJob = new SetListLengthJob {
            list = list, ResizeLength = length
        }.Schedule();
        var setValuesJob = new SetArrayValuesJobParallel {
            array = list.AsDeferredJobArray()
        };

        setLengthJob.Complete();

        setValuesJob.Schedule(list, 3).Complete();

        Assert.AreEqual(length, list.Length);
        for (int i = 0; i != list.Length; i++)
        {
            Assert.AreEqual(length, list[i]);
        }

        list.Dispose();
    }