예제 #1
0
 internal void RevertWritingTransaction(IRootNode currentArtRoot)
 {
     lock (_writeLock)
     {
         currentArtRoot.Dispose();
         _writingTransaction = null;
         TryDequeWaiterForWritingTransaction();
     }
 }
예제 #2
0
        void NewWrittingTransactionUnsafe(TaskCompletionSource <IKeyValueDBTransaction> tcs)
        {
            FreeWaitingToDispose();
            var newTransactionRoot = LastCommited;

            _lastCommited       = newTransactionRoot.Snapshot();
            _writingTransaction = new ArtInMemoryKeyValueDBTransaction(this, newTransactionRoot, true, false);
            tcs.TrySetResult(_writingTransaction);
        }
예제 #3
0
 internal void CommitWrittingTransaction(IRootNode artRoot)
 {
     lock (_writeLock)
     {
         _writingTransaction = null;
         if (_lastCommited.Dereference())
         {
             _lastCommited.Dispose();
         }
         _lastCommited = artRoot;
         TryDequeWaiterForWrittingTransaction();
     }
 }
예제 #4
0
 internal void RevertWrittingTransaction(IRootNode currentArtRoot)
 {
     lock (_writeLock)
     {
         currentArtRoot.RevertTo(_lastCommited);
         if (_lastCommited.Dereference())
         {
             _lastCommited.Dispose();
         }
         _lastCommited       = currentArtRoot;
         _writingTransaction = null;
         TryDequeWaiterForWrittingTransaction();
     }
 }
예제 #5
0
        ArtInMemoryKeyValueDBTransaction NewWritingTransactionUnsafe()
        {
            FreeWaitingToDispose();
            var newTransactionRoot = _lastCommited.CreateWritableTransaction();

            try
            {
                var tr = new ArtInMemoryKeyValueDBTransaction(this, newTransactionRoot, true, false);
                _writingTransaction = tr;
                return(tr);
            }
            catch
            {
                newTransactionRoot.Dispose();
                throw;
            }
        }
예제 #6
0
 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);
     }
 }