Ejemplo n.º 1
0
 public override void Retain()
 {
     if (IsDisposed)
     {
         PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock));
     }
     Interlocked.Increment(ref _referenceCount);
 }
 public override Span <byte> AsSpan(int index, int length)
 {
     if (IsDisposed)
     {
         PipelinesThrowHelper.ThrowObjectDisposedException(nameof(DisposeTrackingBufferPool));
     }
     return(_array.Slice(index, length));
 }
Ejemplo n.º 3
0
 protected override bool TryGetArray(out ArraySegment <byte> arraySegment)
 {
     if (IsDisposed)
     {
         PipelinesThrowHelper.ThrowObjectDisposedException(nameof(DisposeTrackingBufferPool));
     }
     arraySegment = new ArraySegment <byte>(_array);
     return(true);
 }
Ejemplo n.º 4
0
 // In kestrel both MemoryPoolBlock and OwnedMemory end up in the same assembly so
 // this method access modifiers need to be `protected internal`
 protected override bool TryGetArray(out ArraySegment <byte> arraySegment)
 {
     if (IsDisposed)
     {
         PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock));
     }
     arraySegment = new ArraySegment <byte>(Slab.Array, _offset, _length);
     return(true);
 }
Ejemplo n.º 5
0
 public override MemoryHandle Pin()
 {
     if (IsDisposed)
     {
         PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock));
     }
     Retain();
     unsafe
     {
         return(new MemoryHandle(this, (Slab.NativePointer + _offset).ToPointer()));
     }
 }