Ejemplo n.º 1
0
 private static BookKeeperPool instance()
 {
     if (_instance == null)
     {
         lock (locker)
         {
             if (_instance == null)
             {
                 _instance = new BookKeeperPool();
             }
         }
     }
     return(_instance);
 }
Ejemplo n.º 2
0
        public static SimpleBK getSimpleBK(ResourceType rtype, string name)
        {
            SimpleBK       bk;
            BookKeeperPool ins = instance();

            if (ins.freeSimple.Count > 0)
            {
                bk = ins.freeSimple.Dequeue();
                bk.init(rtype, name);
#if DEBUG
                Console.Error.WriteLine("<BookKeeperPool> Releasing SimpleBK from queue for {1}, new size = {0}", instance().freeSimple.Count, name);
#endif
                return(bk);
            }
            else
            {
#if DEBUG
                Console.Error.WriteLine("<BookKeeperPool> Creating new SimpleBK for {0}", name);
#endif
                ins.poolSize++;
                return(new SimpleBK(rtype, name));
            }
        }