public BufferHandle Pin() { if (_owner != null) { return(_owner.Pin(_index)); } var handle = GCHandle.Alloc(_array, GCHandleType.Pinned); unsafe { var pointer = OwnedBuffer <T> .Add((void *)handle.AddrOfPinnedObject(), _index); return(new BufferHandle(null, pointer, handle)); } }
public void Dispose() { switch (ReferenceCountingSettings.OwnedMemory) { case ReferenceCountingMethod.Interlocked: ((IKnown)_owner).Release(); break; case ReferenceCountingMethod.ReferenceCounter: ReferenceCounter.Release(_owner); break; case ReferenceCountingMethod.None: break; } _owner = null; }
internal DisposableReservation(OwnedBuffer <T> owner) { _owner = owner; switch (ReferenceCountingSettings.OwnedMemory) { case ReferenceCountingMethod.Interlocked: ((IKnown)_owner).AddReference(); break; case ReferenceCountingMethod.ReferenceCounter: ReferenceCounter.AddReference(_owner); break; case ReferenceCountingMethod.None: break; } }
internal ReadOnlyBuffer(OwnedBuffer <T> owner, int index, int length) { _owner = owner; _index = index; _length = length; }
public void Dispose() { _owner.Release(); _owner = null; }
internal DisposableReservation(OwnedBuffer <T> owner) { _owner = owner; _owner.Retain(); }