/// <summary> /// Get a buffer from the pool. It should be recycled later calling at <see cref="Recycle"/> /// </summary> /// <param name="byteCountPowerOf2">minimum byte count = 1 << this</param> /// <param name="useGlobalPool">Use a pool unique for each thread (false) or a shared pool between threads (true)</param> public static BitBuffer GetPooled(int bitCount, bool useGlobalPool = false) { int byteCount = bitCount / 8; if ((bitCount & 0x7) != 0) { byteCount += 1; } var obj = PooledBufferHolder.GetPooledOrNew(byteCount, useGlobalPool); return(new BitBuffer(obj, bitCount)); }
/// <summary> /// Get a buffer from the pool. It should be recycled later calling at <see cref="Recycle"/> /// </summary> /// <param name="byteCountPowerOf2">minimum byte count = 1 << this</param> /// <param name="useGlobalPool">Use a pool unique for each thread (false) or a shared pool between threads (true)</param> public static ByteBuffer GetPooled(int byteCount, bool useGlobalPool = false) { var obj = PooledBufferHolder.GetPooledOrNew(byteCount, useGlobalPool); return(new ByteBuffer(obj, byteCount)); }