Ejemplo n.º 1
0
 public void Pool(ChunkEventBucket bucket)
 {
     lock (monitor)
     {
         poolBucket.Push(bucket);
     }
 }
Ejemplo n.º 2
0
 public bool GetBucket(out ChunkEventBucket bucket)
 {
     lock (monitor)
     {
         if (currentBucket.Count > 0)
         {
             bucket = currentBucket;
             if (poolBucket.Count > 0)
             {
                 currentBucket = poolBucket.Pop();
             }
             else
             {
                 currentBucket = new ChunkEventBucket(this);
             }
             if (hasBits)
             {
                 hasBits = false;
                 Array.Clear(bits, 0, bits.Length);
             }
             return(true);
         }
         else
         {
             bucket = null;
             return(false);
         }
     }
 }
Ejemplo n.º 3
0
 public void Enqueue(ChunkEventBucket bucket)
 {
     lock (monitor)
     {
         queue.Enqueue(bucket);
     }
 }
Ejemplo n.º 4
0
        void Execute(ChunkEventBucket bucket)
        {
            while (bucket.Count > 0)
            {
                var e = bucket.Dequeue();
                e.Execute();
                e.Pool();
            }

            bucket.Pool();
        }
Ejemplo n.º 5
0
        public ChunkEventManager(HashSet <ChunkEventManager> hashSet, Type managerType)
        {
            bits             = new short[4096];
            this.hashSet     = hashSet;
            this.managerType = managerType;
            currentBucket    = new ChunkEventBucket(this);

            lock (hashSet)
            {
                hashSet.Add(this);
            }
        }