Inheritance: IDisposable
Beispiel #1
0
        protected void CreateHandles(long capacity)
        {
            if (NativeStream.Length > capacity)
            {
                capacity = NativeStream.Length;
            }

            Handle = MemoryMappedFile.CreateFromFile(
                NativeStream, null, capacity,
                MemoryMappedFileAccess.ReadWrite,
                null, HandleInheritability.None, true
                );
            HeaderView     = Handle.CreateViewAccessor(0, HeaderSize);
            StreamCapacity = capacity;
            Cache          = new ViewCache(Handle, StreamCapacity);
        }
Beispiel #2
0
 private void DisposeViews()
 {
     if (Cache != null)
     {
         Cache.Dispose();
         Cache = null;
     }
     if (HeaderView != null)
     {
         // https://connect.microsoft.com/VisualStudio/feedback/details/552859/memorymappedviewaccessor-flush-throws-ioexception
         // HeaderView.Dispose();
         HeaderView.SafeMemoryMappedViewHandle.Dispose();
         HeaderView = null;
     }
     if (Handle != null)
     {
         Handle.Dispose();
         Handle = null;
     }
 }
Beispiel #3
0
 private void DisposeViews()
 {
     if (Cache != null) {
         Cache.Dispose();
         Cache = null;
     }
     if (HeaderView != null) {
         // https://connect.microsoft.com/VisualStudio/feedback/details/552859/memorymappedviewaccessor-flush-throws-ioexception
         // HeaderView.Dispose();
         HeaderView.SafeMemoryMappedViewHandle.Dispose();
         HeaderView = null;
     }
     if (Handle != null) {
         Handle.Dispose();
         Handle = null;
     }
 }
Beispiel #4
0
        protected void CreateHandles(long capacity)
        {
            if (NativeStream.Length > capacity)
                capacity = NativeStream.Length;

            Handle = MemoryMappedFile.CreateFromFile(
                NativeStream, null, capacity,
                MemoryMappedFileAccess.ReadWrite,
                null, HandleInheritability.None, true
            );
            HeaderView = Handle.CreateViewAccessor(0, HeaderSize);
            StreamCapacity = capacity;
            Cache = new ViewCache(Handle, StreamCapacity);
        }
Beispiel #5
0
 public StreamRange(StreamRef stream, ViewCache.CacheEntry cacheEntry, long offset, uint size)
 {
     Stream = stream;
     CacheEntry = cacheEntry;
     View = null;
     Offset = offset;
     Size = size;
     Buffer = cacheEntry.Buffer;
     IsDisposed = false;
     unchecked {
         Pointer = cacheEntry.Pointer + cacheEntry.PointerOffset;
         Pointer += (offset - cacheEntry.Offset);
     }
 }