public override void Sync() { if (Disposed) { ThrowAlreadyDisposedException(); } var currentState = GetPagerStateAndAddRefAtomically(); try { using (var metric = Options.IoMetrics.MeterIoRate(FileName, IoMetrics.MeterType.DataSync, 0)) { foreach (var allocationInfo in currentState.AllocationInfos) { metric.IncrementSize(allocationInfo.Size); if ( Win32MemoryMapNativeMethods.FlushViewOfFile(allocationInfo.BaseAddress, new IntPtr(allocationInfo.Size)) == false) { throw new Win32Exception(); } } if (Win32MemoryMapNativeMethods.FlushFileBuffers(_handle) == false) { throw new Win32Exception(); } } } finally { currentState.Release(); } }
public override void Sync() { ThrowObjectDisposedIfNeeded(); if (PagerState.AllocationInfos.Any(allocationInfo => Win32MemoryMapNativeMethods.FlushViewOfFile(allocationInfo.BaseAddress, new IntPtr(allocationInfo.Size)) == false)) { throw new Win32Exception(); } if (Win32MemoryMapNativeMethods.FlushFileBuffers(_handle) == false) { throw new Win32Exception(); } }
public override void Sync(long totalUnsynced) { if (DisposeOnceRunner.Disposed) { ThrowAlreadyDisposedException(); } if ((_fileAttributes & Win32NativeFileAttributes.Temporary) == Win32NativeFileAttributes.Temporary || (_fileAttributes & Win32NativeFileAttributes.DeleteOnClose) == Win32NativeFileAttributes.DeleteOnClose) { return; // no need to do this } var currentState = GetPagerStateAndAddRefAtomically(); try { using (var metric = Options.IoMetrics.MeterIoRate(FileName.FullPath, IoMetrics.MeterType.DataSync, 0)) { foreach (var allocationInfo in currentState.AllocationInfos) { metric.IncrementFileSize(allocationInfo.Size); if ( Win32MemoryMapNativeMethods.FlushViewOfFile(allocationInfo.BaseAddress, new IntPtr(allocationInfo.Size)) == false) { var lasterr = Marshal.GetLastWin32Error(); throw new Win32Exception(lasterr); } } metric.IncrementSize(totalUnsynced); if (Win32MemoryMapNativeMethods.FlushFileBuffers(_handle) == false) { var lasterr = Marshal.GetLastWin32Error(); throw new Win32Exception(lasterr); } } } finally { currentState.Release(); } }
public override void Sync() { if (Disposed) { ThrowAlreadyDisposedException(); } foreach (var allocationInfo in PagerState.AllocationInfos) { if (Win32MemoryMapNativeMethods.FlushViewOfFile(allocationInfo.BaseAddress, new IntPtr(allocationInfo.Size)) == false) { throw new Win32Exception(); } } if (Win32MemoryMapNativeMethods.FlushFileBuffers(_handle) == false) { throw new Win32Exception(); } // TODO : Measure IO times (RavenDB-4659) - Flushed & sync {sizeToWrite/1024:#,#} kb in {sp.ElapsedMilliseconds:#,#} ms }