public override void Retain() { if (IsDisposed) { PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock)); } Interlocked.Increment(ref _referenceCount); }
protected override bool TryGetArray(out ArraySegment <byte> buffer) { if (IsDisposed) { PipelinesThrowHelper.ThrowObjectDisposedException(nameof(UnownedBuffer)); } buffer = _buffer; return(true); }
protected override bool TryGetArray(out ArraySegment <byte> buffer) { if (IsDisposed) { PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock)); } buffer = new ArraySegment <byte>(Slab.Array, _offset, _length); return(true); }
protected override unsafe bool TryGetPointerInternal(out void *pointer) { if (IsDisposed) { PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock)); } pointer = (Slab.NativePointer + _offset).ToPointer(); return(true); }
public override Span <byte> AsSpan(int index, int length) { if (IsDisposed) { PipelinesThrowHelper.ThrowObjectDisposedException(nameof(UnownedBuffer)); } if (length > _buffer.Count - index) { throw new ArgumentOutOfRangeException(); } return(new Span <byte>(_buffer.Array, _buffer.Offset + index, length)); }
public override Span <byte> AsSpan(int index, int length) { if (IsDisposed) { PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock)); } if (length > _length - index) { throw new ArgumentOutOfRangeException(); } return(new Span <byte>(Slab.Array, _offset + index, length)); }
public override BufferHandle Pin() { if (IsDisposed) { PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock)); } Retain(); unsafe { return(new BufferHandle(this, (Slab.NativePointer + _offset).ToPointer())); } }
public override BufferHandle Pin(int index = 0) { if (IsDisposed) { PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock)); } if (index > _length) { PipelinesThrowHelper.ThrowArgumentOutOfRangeException(_length, index); } Retain(); unsafe { return(new BufferHandle(this, (Slab.NativePointer + _offset + index).ToPointer())); } }