Example #1
0
    public void ScheduleDerivedArrayAllowDerivingArrayAgain()
    {
        var list = new NativeList <int> (1, Allocator.Persistent);

        // The scheduled job only receives a NativeArray thus it can't be resized
        var writeJobHandle = new NativeArrayTest(list).Schedule();

        // For that reason casting here is legal, as opposed to AddElementToListFromJobInvalidatesArray case where it is not legal
        // Since we NativeList is passed to the job
        NativeArray <int> array = list;

        writeJobHandle.Complete();
        list.Dispose();
    }
Example #2
0
    public void ScheduleDerivedArrayAllowDerivingArrayAgain()
    {
        var list = new NativeList <int>(1, Allocator.Persistent);

        // The scheduled job only receives a NativeArray thus it can't be resized
        var writeJobHandle = new NativeArrayTest(list).Schedule();

        // For that reason casting here is legal, as opposed to AddElementToListFromJobInvalidatesArray case where it is not legal
        // Since we NativeList is passed to the job
#pragma warning disable 0219 // assigned but its value is never used
        NativeArray <int> array = list;
#pragma warning restore 0219

        list.Dispose(writeJobHandle);
    }
Example #3
0
    public void AsArrayJobKeepsAsArrayValid()
    {
        var list = new NativeList <int>(Allocator.TempJob);

        list.Add(0);
        var arrayBeforeSchedule = list.AsArray();

        var jobData = new NativeArrayTest(list);
        var job     = jobData.Schedule();

        job.Complete();

        Assert.AreEqual(0, arrayBeforeSchedule[0]);

        list.Dispose();
    }