Пример #1
0
        private unsafe RioBufferSegment GetSegmentFromMemory(Memory <byte> memory)
        {
            var  spanPtr = (IntPtr)memory.UnsafePointer;
            long startAddress;
            long spanAddress = spanPtr.ToInt64();
            var  bufferId    = _rioThread.GetBufferId(spanPtr, out startAddress);

            checked
            {
                var offset = (uint)(spanAddress - startAddress);
                return(new RioBufferSegment(bufferId, offset, (uint)memory.Length));
            }
        }
Пример #2
0
        private unsafe RioBufferSegment GetSegmentFromMemory(Memory <byte> memory)
        {
            void *pointer;

            if (!memory.TryGetPointer(out pointer))
            {
                throw new InvalidOperationException("Memory needs to be pinned");
            }
            var  spanPtr = (IntPtr)pointer;
            long startAddress;
            long spanAddress = spanPtr.ToInt64();
            var  bufferId    = _rioThread.GetBufferId(spanPtr, out startAddress);

            checked
            {
                var offset = (uint)(spanAddress - startAddress);
                return(new RioBufferSegment(bufferId, offset, (uint)memory.Length));
            }
        }
Пример #3
0
        private RioBufferSegment GetSegmentFromSpan(BufferSpan span)
        {
            var bufferId = _rioThread.GetBufferId(span.BufferBasePtr);

            return(new RioBufferSegment(bufferId, (uint)span.Offset, (uint)span.Length));
        }