public static MemoryMappedFileSegmentFactory Open(MemoryMappedFile file, long offset = 0, long length = -1, MemoryMappedFileAccess access = MemoryMappedFileAccess.Read, int defaultSegmentWords = DefaultSegmentWords, bool leaveOpen = false) { MemoryMappedFileSegmentFactory obj = null; try { obj = Cache <MemoryMappedFileSegmentFactory> .Pop() ?? new MemoryMappedFileSegmentFactory(); obj.Init(file, offset, length, access, defaultSegmentWords, leaveOpen); var tmp = obj; obj = null; // to avoid finally return(tmp); } finally { Cache <MemoryMappedFileSegmentFactory> .Push(obj); } }
public static MemoryMappedFileSegmentFactory Open(string path, long offset = 0, long length = -1, MemoryMappedFileAccess access = MemoryMappedFileAccess.Read, int defaultSegmentWords = DefaultSegmentWords) { MemoryMappedFileSegmentFactory obj = null; try { obj = Cache <MemoryMappedFileSegmentFactory> .Pop() ?? new MemoryMappedFileSegmentFactory(); obj.Init(path, 0, length, FileMode.Open, access, defaultSegmentWords); var tmp = obj; obj = null; // to avoid finally return(tmp); } finally { Cache <MemoryMappedFileSegmentFactory> .Push(obj); } }