예제 #1
0
        private void UnPin()
        {
            Debug.Assert(_buffersHandle.IsAllocated);
            Debug.Assert(_thisHandle.IsAllocated);

            _buffersHandle.Free();
            _thisHandle.Free();

            _bufferManager   = null;
            _endPointManager = null;
        }
        private IMemoryOwner <byte> GetBlockSlow()
        {
            uint allocSize = _nextAllocSize;

            _nextAllocSize = Math.Min(allocSize * 3u / 2u, 4 * 1024 * 1024);

            Memory <byte> memory = new RegisteredMemoryManager((int)allocSize).Memory;

            for (int i = (int)_blockSize; i < memory.Length; i += (int)_blockSize)
            {
                Push(new OwnedMemory(memory.Slice(i, (int)_blockSize)));
            }

            var ret = new OwnedMemory(memory.Slice(0, (int)_blockSize));

            ret.OwningList = this;
            return(ret);
        }
예제 #3
0
 private void Prepare(ReadOnlyMemory <byte> buffer, RegisteredEndPoint remoteEndPoint)
 {
     _bufferManager   = SetBuffer(ref _buffers[0], buffer);
     _endPointManager = SetBuffer(ref _buffers[1], remoteEndPoint.Memory);
     Pin();
 }
예제 #4
0
 private void Prepare(ReadOnlyMemory <byte> buffer)
 {
     _bufferManager = SetBuffer(ref _buffers[0], buffer);
     Pin();
 }