コード例 #1
0
 public void Pool(ChunkEventBucket bucket)
 {
     lock (monitor)
     {
         poolBucket.Push(bucket);
     }
 }
コード例 #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);
         }
     }
 }
コード例 #3
0
ファイル: ChunkEventThread.cs プロジェクト: shsa/unity
 public void Enqueue(ChunkEventBucket bucket)
 {
     lock (monitor)
     {
         queue.Enqueue(bucket);
     }
 }
コード例 #4
0
ファイル: ChunkEventThread.cs プロジェクト: shsa/unity
        void Execute(ChunkEventBucket bucket)
        {
            while (bucket.Count > 0)
            {
                var e = bucket.Dequeue();
                e.Execute();
                e.Pool();
            }

            bucket.Pool();
        }
コード例 #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);
            }
        }