public void DisposeInsideStructOnJobCompletion(CanContainDisposedStruct c, ScheduleType scheduleType) { switch (scheduleType) { case ScheduleType.Run: Entities.WithDisposeOnCompletion(c).ForEach((ref EcsTestFloatData _) => { c.SupportsDisposeOnCompletion.CheckCanRead(); }).Run(); break; case ScheduleType.Schedule: Entities.WithDisposeOnCompletion(c).ForEach((ref EcsTestFloatData _) => { var temp = c; c.SupportsDisposeOnCompletion.CheckCanRead(); }).Schedule(default).Complete(); break; case ScheduleType.ScheduleParallel: Entities.WithReadOnly(c).WithDisposeOnCompletion(c).ForEach((ref EcsTestFloatData _) => { var temp = c; c.SupportsDisposeOnCompletion.CheckCanRead(); }).Schedule(default).Complete(); break; } }
public void DeallocateInsideStructOnJobCompletion_WithRun_DeallocatesAtEnd() { m_Manager.CreateEntity(typeof(EcsTestFloatData)); var c = new CanContainDisposedStruct { SupportsDeallocateOnJobCompletion = SupportsDeallocateOnJobCompletion.Create() }; try { Assert.DoesNotThrow(() => TestSystem.DeallocateInsideStructOnJobCompletion_WithRun(c)); Assert.IsTrue(c.SupportsDeallocateOnJobCompletion.HasBeenDisposed(), "Dispose has not been called for contained struct"); } finally { c.SupportsDeallocateOnJobCompletion.Release(); } }
public void DisposeInsideStructOnJobCompletion_DisposesAtEnd([Values] ScheduleType scheduleType) { m_Manager.CreateEntity(typeof(EcsTestFloatData)); var c = new CanContainDisposedStruct { SupportsDisposeOnCompletion = new SupportsDisposeOnCompletion(Allocator.Temp) }; try { Assert.DoesNotThrow(() => TestSystem.DisposeInsideStructOnJobCompletion(c, scheduleType)); Assert.IsTrue(c.SupportsDisposeOnCompletion.HasBeenDisposed(), "Dispose has not been called for contained struct"); } finally { c.SupportsDisposeOnCompletion.Release(); } }
public void DeallocateInsideStructOnJobCompletion_WithRun(CanContainDisposedStruct c) { Entities.WithDeallocateOnJobCompletion(c).ForEach((ref EcsTestFloatData _) => { c.SupportsDeallocateOnJobCompletion.CheckCanRead(); }).Run(); }