internal virtual void InitBeforeConvert(SharedMemoryBuffer buffer)
 {
     if (InitValue != null)
     {
         InitValue(buffer);
         InitValue = null;
     }
 }
 internal virtual void InitNew()
 {
     if (Size > long.MaxValue)
     {
         throw new ArgumentOutOfRangeException("cannot allocate memory larger than long.MaxValue");
     }
     Buffer = new SharedMemoryBuffer((IntPtr)(long)Size);
     Buffer.Initialize(Size);
 }
Esempio n. 3
0
        public SharedMemoryBuffer CreateView(long position, ulong numBytes)
        {
            if (position < 0 || numBytes < 0)
            {
                throw new ArgumentOutOfRangeException("position or length cannot be negtive value");
            }
            long BufferStart = Handle.ToInt64();
            long BufferEnd   = BufferStart + (long)ByteLength;

            long start = position + BufferStart;
            long end   = start + (long)numBytes;//potencial overflow, let dotnet handle this :)

            if (start > BufferEnd || end > BufferEnd)
            {
                throw new ArgumentException("cannot project data accessor outside data area");
            }
            SharedMemoryBuffer result = new SharedMemoryBuffer((IntPtr)start, numBytes, false);

            return(result);
        }
 protected virtual void InitWindow(SharedMemoryBuffer source, long position)
 {
     Buffer = source.CreateView(position, Size);
 }
 internal virtual void InitWindow(IntPtr handle, bool ownsHandle)
 {
     Buffer = new SharedMemoryBuffer(handle, Size, ownsHandle);
 }