Exemple #1
0
 public override void Retain()
 {
     if (IsDisposed)
     {
         PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock));
     }
     Interlocked.Increment(ref _referenceCount);
 }
Exemple #2
0
 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);
 }
Exemple #4
0
 protected override unsafe bool TryGetPointerInternal(out void *pointer)
 {
     if (IsDisposed)
     {
         PipelinesThrowHelper.ThrowObjectDisposedException(nameof(MemoryPoolBlock));
     }
     pointer = (Slab.NativePointer + _offset).ToPointer();
     return(true);
 }
Exemple #5
0
 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));
 }
Exemple #7
0
 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()));
     }
 }