Example #1
0
 public override void Retain()
 {
     if (IsDisposed)
     {
         RioPipelinesThrowHelper.ThrowObjectDisposedException(nameof(RioMemoryPoolBlock));
     }
     Interlocked.Increment(ref _referenceCount);
 }
Example #2
0
 public override Span <byte> GetSpan()
 {
     if (IsDisposed)
     {
         RioPipelinesThrowHelper.ThrowObjectDisposedException(nameof(RioMemoryPoolBlock));
     }
     return(new Span <byte>(Slab.Array, _offset, _length));
 }
Example #3
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)
     {
         RioPipelinesThrowHelper.ThrowObjectDisposedException(nameof(RioMemoryPoolBlock));
     }
     arraySegment = new ArraySegment <byte>(Slab.Array, _offset, _length);
     return(true);
 }
Example #4
0
 public override MemoryHandle Pin()
 {
     if (IsDisposed)
     {
         RioPipelinesThrowHelper.ThrowObjectDisposedException(nameof(RioMemoryPoolBlock));
     }
     Retain();
     unsafe
     {
         return(new MemoryHandle(this, (Slab.NativePointer + _offset).ToPointer()));
     }
 }