Esempio n. 1
0
            public override byte[] TakeBuffer(int bufferSize)
            {
                Fx.Assert(bufferSize >= 0, "caller must ensure a non-negative argument");

                BufferPool bufferPool = FindPool(bufferSize);

                if (bufferPool != null)
                {
                    byte[] buffer = bufferPool.Take();
                    if (buffer != null)
                    {
                        bufferPool.DecrementCount();
                        return(buffer);
                    }
                    if (bufferPool.Peak == bufferPool.Limit)
                    {
                        bufferPool.Misses++;
                        if (++totalMisses >= maxMissesBeforeTuning)
                        {
                            TuneQuotas();
                        }
                    }
                    return(InternalBufferManager.AllocateByteArray(bufferPool.BufferSize));
                }
                else
                {
                    return(InternalBufferManager.AllocateByteArray(bufferSize));
                }
            }
Esempio n. 2
0
 public BufferManagerByteArray(byte[] bytes, InternalBufferManager bufferManager)
 {
     this.Bytes         = bytes;
     this.BufferManager = bufferManager;
     this.references    = 1;
 }
Esempio n. 3
0
 public BufferedInputStream(byte[] bytes, int bufferSize, InternalBufferManager bufferManager)
 {
     this.data        = new BufferManagerByteArray(bytes, bufferManager);
     this.innerStream = new MemoryStream(bytes, 0, bufferSize);
 }
Esempio n. 4
0
 public override byte[] TakeBuffer(int bufferSize)
 {
     return(InternalBufferManager.AllocateByteArray(bufferSize));
 }
 public BufferManagerByteArray(byte[] bytes, InternalBufferManager bufferManager)
 {
     Bytes         = bytes;
     BufferManager = bufferManager;
     references    = 1;
 }
 public BufferManagerByteArray(byte[] bytes, InternalBufferManager bufferManager)
 {
     this.Bytes = bytes;
     this.BufferManager = bufferManager;
     this.references = 1;
 }
 public BufferedInputStream(byte[] bytes, int bufferSize, InternalBufferManager bufferManager)
 {
     this.data = new BufferManagerByteArray(bytes, bufferManager);
     this.innerStream = new MemoryStream(bytes, 0, bufferSize);
 }