public void Commit(ulong commitId, BrightstarProfiler profiler) { if (CanWrite) { foreach (var pageId in _modifiedPages.Keys) { var page = PageCache.Instance.Lookup(_partitionId, pageId) as BinaryFilePage; if (page != null && page.IsDirty) { _backgroundPageWriter.QueueWrite(page, commitId); } } _backgroundPageWriter.Flush(); lock (_restartLock) { _backgroundPageWriter.Shutdown(); _backgroundPageWriter.Dispose(); PageCache.Instance.Clear(_partitionId); UpdatePartitionId(); _readTxnId = _writeTxnId; _writeTxnId++; _backgroundPageWriter = new BackgroundPageWriter(_persistenceManager.GetOutputStream(_filePath, FileMode.Open)); } } else { throw new InvalidOperationException("Attempt to Commit on a read-only store instance"); } }
/// <summary> /// Close the store, releasing any resources (such as file handles) it may be using /// </summary> public void Close() { if (_stream != null) { _stream.Close(); } if (_backgroundPageWriter != null) { _backgroundPageWriter.Shutdown(); _backgroundPageWriter.Dispose(); _backgroundPageWriter = null; } }
/// <summary> /// Close the store, releasing any resources (such as file handles) it may be using /// </summary> public void Close() { lock (this) { if (_stream != null) { _stream.Close(); _stream = null; } if (_backgroundPageWriter != null) { _backgroundPageWriter.Dispose(); _backgroundPageWriter = null; } } }