예제 #1
0
        private PoolNode Create()
        {
            PoolNode node = emptyNodesPool.GetNode();

            node.Value = factory();
            return(node);
        }
예제 #2
0
 public void ReturnPooledInstance(object instance)
 {
     if (count < poolParams.Size || poolParams.Size < 0)
     {
         PoolNode node = emptyNodesPool.GetNode();
         node.Value = instance;
         Push(node);
     }
 }
예제 #3
0
        private T Pop()
        {
            PoolNode node = head;

            head      = head.Next;
            node.Next = null;
            T value = (T)node.Value;

            emptyNodesPool.ReturnNode(node);
            count--;
            return(value);
        }
예제 #4
0
 private void Push(PoolNode node)
 {
     node.Next = head;
     head      = node;
     count++;
 }
예제 #5
0
 public void Clear()
 {
     head = null;
     emptyNodesPool.Clear();
 }