示例#1
0
        /// <inheritdoc />
        public override MemoryHandle Pin(int elementIndex = 0)
        {
            DebugGuard.NotDisposed(this.disposed == 1, this.GetType().Name);
            DebugGuard.NotDisposed(this.lifetimeGuard.IsDisposed, this.lifetimeGuard.GetType().Name);

            // Will be released in Unpin
            this.lifetimeGuard.AddRef();

            void *pbData = Unsafe.Add <T>(this.Pointer, elementIndex);

            return(new MemoryHandle(pbData, pinnable: this));
        }
示例#2
0
 public override Span <T> GetSpan()
 {
     DebugGuard.NotDisposed(this.disposed == 1, this.GetType().Name);
     DebugGuard.NotDisposed(this.lifetimeGuard.IsDisposed, this.lifetimeGuard.GetType().Name);
     return(new(this.Pointer, this.lengthInElements));
 }