private PoolNode Create() { PoolNode node = emptyNodesPool.GetNode(); node.Value = factory(); return(node); }
public void ReturnPooledInstance(object instance) { if (count < poolParams.Size || poolParams.Size < 0) { PoolNode node = emptyNodesPool.GetNode(); node.Value = instance; Push(node); } }
private T Pop() { PoolNode node = head; head = head.Next; node.Next = null; T value = (T)node.Value; emptyNodesPool.ReturnNode(node); count--; return(value); }
private void Push(PoolNode node) { node.Next = head; head = node; count++; }
public void Clear() { head = null; emptyNodesPool.Clear(); }