/// <summary> /// Returns a new reusable value container containing <paramref name="value"/>. /// It will try to take from the pool, otherwise it will create a new object. /// Call <see cref="Dispose"/> when you are finished with this to add it back to the pool. /// </summary> public static ReusableValueContainer <T> New(T value) { ReusableValueContainer <T> node = _pool.IsNotEmpty ? _pool.Pop() : new ReusableValueContainer <T>(); node.Value = value; return(node); }
/// <summary> /// Only use this if you know the queue is not empty. /// </summary> public void PushRisky(T item) { _queue.PushRisky(ReusableValueContainer <T> .New(item)); }
/// <summary> /// Only use this if you know the queue is not empty. /// </summary> public void EnqueueRisky(T item) { _queue.EnqueueRisky(ReusableValueContainer <T> .New(item)); }
public static void ClearPooledNodes() { ReusableValueContainer <T> .ClearPool(); }
public void Push(T item) { _stack.Push(ReusableValueContainer <T> .New(item)); }