AllocateByteArray() public static method

public static AllocateByteArray ( int size ) : byte[]
size int
return byte[]
Ejemplo 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));
                }
            }
Ejemplo n.º 2
0
 public override byte[] TakeBuffer(int bufferSize)
 {
     return(InternalBufferManager.AllocateByteArray(bufferSize));
 }