Exemple #1
0
        public static void ReturnPool(int groupId)
        {
            // Reset and return the pool for this thread to the specified group.
            Stack <ThreadStaticPool <T> > pools = GetPools(groupId);

            lock (pools)
            {
                _instance.Clear();
                pools.Push(_instance);
                _instance = null;
            }
        }
Exemple #2
0
 public static void PreparePool(int groupId)
 {
     // Prepare the pool for this thread, ideally using an existing one from the specified group.
     if (_instance == null)
     {
         Stack <ThreadStaticPool <T> > pools = GetPools(groupId);
         lock (pools)
         {
             _instance = (pools.Count != 0) ? pools.Pop() : new ThreadStaticPool <T>(PoolSizeIncrement * 2);
         }
     }
 }