コード例 #1
0
ファイル: SlabMemoryPool.cs プロジェクト: gedo4547/letter
        public override IMemoryOwner <byte> Rent(int size = AnySize)
        {
            if (size > _blockSize)
            {
                MemoryPoolThrowHelper.ThrowArgumentOutOfRangeException_BufferRequestTooLarge(_blockSize);
            }

            var block = Lease();

            return(block);
        }
コード例 #2
0
        public override IMemoryOwner <byte> Rent(int size = AnySize)
        {
            if (size > _blockSize)
            {
                MemoryPoolThrowHelper.ThrowArgumentOutOfRangeException_BufferRequestTooLarge(_blockSize);
            }

            if (_isDisposed)
            {
                MemoryPoolThrowHelper.ThrowObjectDisposedException(MemoryPoolThrowHelper.ExceptionArgument.MemoryPool);
            }

            if (_blocks.TryDequeue(out var block))
            {
                // block successfully taken from the stack - return it
                return(block);
            }
            return(new MemoryPoolBlock(this, BlockSize));
        }