public void FreeWorkItem(ref WorkItem workItem) { if (workItem == null) { return; } // don't kill the big buffers. main point of this pool is to hopefully re-use them later. workItem.Next = null; poolWorkItems?.Return(ref workItem); }
public void FreeCompressedWorkItem(ref CompressedWorkItem compressedItem) { // don't kill the big buffers. main point of this pool is to hopefully re-use them later. if (compressedItem == null) { return; } // keep the capacity, but kill the contents. // also, go a little overkill and kill the references to WorkItem list heads inside the List. if (compressedItem.ListHeads != null) { for (var i = 0; i < compressedItem.ListHeads.Count; ++i) { compressedItem.ListHeads[0] = null; } compressedItem.ListHeads.Clear(); } poolCompressedWorkItems?.Return(ref compressedItem); }