public T Pop() { if (Count == 0) { throw new InvalidOperationException(); } if (_tail.Count == 0) { var prev = _tail.Prev; _tail.Prev = null; var releaseNode = _tail; Array.Clear(releaseNode.Array, 0, releaseNode.Array.Length); _nodePool.Release(releaseNode); _tail = prev; } Count--; return(_tail.Array[--_tail.Count]); }
public void Release(LinkedListStackNode <T> item) { if (NodeSize != item.Array.Length) { throw new InvalidOperationException(); } _stackPool.Push(item); }
public void PushRef(ref T thread) { if (_tail == null || _tail.Count == NodeSize) { var node = _nodePool.Get(); node.Prev = _tail; _tail = node; } _tail.Array[_tail.Count++] = thread; Count++; }