/// <summary> /// Safely disposes of this container and deallocates its memory when the jobs that use it have completed. /// </summary> /// <remarks>You can call this function dispose of the container immediately after scheduling the job. Pass /// the [JobHandle](https://docs.unity3d.com/ScriptReference/Unity.Jobs.JobHandle.html) returned by /// the [Job.Schedule](https://docs.unity3d.com/ScriptReference/Unity.Jobs.IJobExtensions.Schedule.html) /// method using the `jobHandle` parameter so the job scheduler can dispose the container after all jobs /// using it have run.</remarks> /// <param name="dependency">All jobs spawned will depend on this JobHandle.</param> /// <returns>A new job handle containing the prior handles as well as the handle for the job that deletes /// the container.</returns> public JobHandle Dispose(JobHandle dependency) { var jobHandle = new DisposeJob { Container = this }.Schedule(dependency); m_Block = null; return(jobHandle); }
public JobHandle Dispose(JobHandle inputDeps) { var jobHandle = new DisposeJob { Container = this }.Schedule(inputDeps); m_Block = null; return(jobHandle); }
internal Writer(ref UnsafeStream stream) { m_BlockStream = stream.m_Block; m_ForeachIndex = int.MinValue; m_ElementCount = -1; m_CurrentBlock = null; m_CurrentBlockEnd = null; m_CurrentPtr = null; m_FirstBlock = null; m_NumberOfBlocks = 0; m_FirstOffset = 0; m_ThreadIndex = 0; }
void Deallocate() { if (m_Block == null) { return; } for (int i = 0; i != m_Block->BlockCount; i++) { UnsafeStreamBlock *block = m_Block->Blocks[i]; while (block != null) { UnsafeStreamBlock *next = block->Next; UnsafeUtility.Free(block, m_Allocator); block = next; } } UnsafeUtility.Free(m_Block->Ranges, m_Allocator); UnsafeUtility.Free(m_Block, m_Allocator); m_Block = null; m_Allocator = Allocator.Invalid; }
void Deallocate() { if (m_Block == null) { return; } for (int i = 0; i != m_Block->BlockCount; i++) { UnsafeStreamBlock *block = m_Block->Blocks[i]; while (block != null) { UnsafeStreamBlock *next = block->Next; Memory.Unmanaged.Free(block, m_Allocator); block = next; } } Memory.Unmanaged.Free(m_Block->Ranges, m_Allocator); Memory.Unmanaged.Free(m_Block, m_Allocator); m_Block = null; m_Allocator = Allocator.None; }