public void Pool(ChunkEventBucket bucket) { lock (monitor) { poolBucket.Push(bucket); } }
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); } } }
public void Enqueue(ChunkEventBucket bucket) { lock (monitor) { queue.Enqueue(bucket); } }
void Execute(ChunkEventBucket bucket) { while (bucket.Count > 0) { var e = bucket.Dequeue(); e.Execute(); e.Pool(); } bucket.Pool(); }
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); } }