コード例 #1
0
ファイル: BufferService.cs プロジェクト: Kayomani/FAP
        /* Do not prepopulate
         * public void Setup(int smallCount, int largeCount)
        {
            lock (smallPool)
            {
                this.smallCount = smallCount;
                for (int i = 0; i < smallCount; i++)
                {
                    MemoryBuffer a = new MemoryBuffer(SmallBuffer);
                    smallPool.Push(a);
                }
            }
            lock (pool)
            {
                this.largeCount = largeCount;
                for (int i = 0; i < largeCount; i++)
                {
                    MemoryBuffer a = new MemoryBuffer(Buffer);
                    pool.Push(a);
                }
            }
        }*/


        public MemoryBuffer GetBuffer()
        {
            lock (pool)
            {
                if (pool.Count > 0)
                    return pool.Pop();
            }
            var a = new MemoryBuffer(Buffer);
            return a;
        }
コード例 #2
0
ファイル: BufferService.cs プロジェクト: Kayomani/FAP
 public MemoryBuffer GetSmallBuffer()
 {
     lock (smallPool)
     {
         if (smallPool.Count > 0)
             return smallPool.Pop();
     }
     var a = new MemoryBuffer(SmallBuffer);
     return a;
 }
コード例 #3
0
ファイル: StreamTokenizer.cs プロジェクト: Kayomani/FAP
 public void ReceiveData(MemoryBuffer buff)
 {
     buffers.Add(buff);
 }
コード例 #4
0
ファイル: BufferService.cs プロジェクト: Kayomani/FAP
 public void FreeBuffer(MemoryBuffer input)
 {
     input.SetDataLocation(0, 0);
     if (input.Data.Length == SmallBuffer)
     {
         lock (smallPool)
             smallPool.Push(input);
     }
     else if (input.Data.Length == Buffer)
     {
         lock (pool)
             pool.Push(input);
     }
     else
     {
         logger.Warn("Tried to free incorrectly sized arg with length: {0}", input.Data.Length);
     }
 }
コード例 #5
0
 public void ReceiveData(MemoryBuffer buff)
 {
     buffers.Add(buff);
 }