Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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;
            }
        }
Ejemplo n.º 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();
 }