예제 #1
0
        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));
            }
        }
예제 #2
0
        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;
        }
예제 #3
0
        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;
            }
        }
예제 #4
0
 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();
 }