internal void RevertWritingTransaction(IRootNode currentArtRoot) { lock (_writeLock) { currentArtRoot.Dispose(); _writingTransaction = null; TryDequeWaiterForWritingTransaction(); } }
void NewWrittingTransactionUnsafe(TaskCompletionSource <IKeyValueDBTransaction> tcs) { FreeWaitingToDispose(); var newTransactionRoot = LastCommited; _lastCommited = newTransactionRoot.Snapshot(); _writingTransaction = new ArtInMemoryKeyValueDBTransaction(this, newTransactionRoot, true, false); tcs.TrySetResult(_writingTransaction); }
internal void CommitWrittingTransaction(IRootNode artRoot) { lock (_writeLock) { _writingTransaction = null; if (_lastCommited.Dereference()) { _lastCommited.Dispose(); } _lastCommited = artRoot; TryDequeWaiterForWrittingTransaction(); } }
internal void RevertWrittingTransaction(IRootNode currentArtRoot) { lock (_writeLock) { currentArtRoot.RevertTo(_lastCommited); if (_lastCommited.Dereference()) { _lastCommited.Dispose(); } _lastCommited = currentArtRoot; _writingTransaction = null; TryDequeWaiterForWrittingTransaction(); } }
ArtInMemoryKeyValueDBTransaction NewWritingTransactionUnsafe() { FreeWaitingToDispose(); var newTransactionRoot = _lastCommited.CreateWritableTransaction(); try { var tr = new ArtInMemoryKeyValueDBTransaction(this, newTransactionRoot, true, false); _writingTransaction = tr; return(tr); } catch { newTransactionRoot.Dispose(); throw; } }
internal IRootNode MakeWritableTransaction(ArtInMemoryKeyValueDBTransaction keyValueDBTransaction, IRootNode artRoot) { lock (_writeLock) { if (_writingTransaction != null) { throw new BTDBTransactionRetryException("Another writing transaction already running"); } if (_lastCommited != artRoot) { throw new BTDBTransactionRetryException("Another writing transaction already finished"); } _writingTransaction = keyValueDBTransaction; var result = _lastCommited.CreateWritableTransaction(); DereferenceRoot(artRoot); return(result); } }