Esempio n. 1
0
 internal virtual void SuspendSinceTransactionsAreStillThreadBound()
 {
     Debug.Assert(_suspendedTransaction == null, "Can't suspend the transaction if it already is suspended.");
     _suspendedTransaction = _bridge.getKernelTransactionBoundToThisThread(true);
     _bridge.unbindTransactionFromCurrentThread();
 }
Esempio n. 2
0
 internal virtual void ResumeSinceTransactionsAreStillThreadBound()
 {
     Debug.Assert(_suspendedTransaction != null, "Can't resume the transaction if it has not first been suspended.");
     _bridge.bindTransactionToCurrentThread(_suspendedTransaction);
     _suspendedTransaction = null;
 }
Esempio n. 3
0
 public PlaceboTransaction(KernelTransaction currentTransaction)
 {
     this._currentTransaction = currentTransaction;
 }
Esempio n. 4
0
        public void Commit()
        {
            object sync = this.sync;

            lock (sync)
            {
                switch (this.state)
                {
                case SaveTransactionState.Initializing:
                case SaveTransactionState.FailedInitialization:
                case SaveTransactionState.Committing:
                case SaveTransactionState.FailedCommit:
                case SaveTransactionState.Committed:
                case SaveTransactionState.RollingBack:
                case SaveTransactionState.FailedRollback:
                case SaveTransactionState.RolledBack:
                    throw new InvalidOperationException($"This transaction is not in a state that allows it to be committed ({this.state})");

                case SaveTransactionState.Initialized:
                    break;

                case SaveTransactionState.Disposed:
                    throw new ObjectDisposedException("SaveTransaction");

                default:
                    throw new InternalErrorException(new InvalidEnumArgumentException("this.state", (int)this.state, typeof(SaveTransactionState)));
                }
                this.state = SaveTransactionState.Committing;
                try
                {
                    DisposableUtil.Free <GuardedStream>(ref this.guardedStream);
                    if (this.kernelTx != null)
                    {
                        this.kernelTx.Commit();
                        this.kernelTx = null;
                        this.tempPath = null;
                    }
                    else
                    {
                        string destFileName = FindUniqueFileName(this.path + ".", ".pdnBak");
                        bool   flag2        = File.Exists(this.path);
                        if (flag2)
                        {
                            File.Move(this.path, destFileName);
                        }
                        File.Move(this.tempPath, this.path);
                        this.tempPath = null;
                        if (flag2)
                        {
                            File.Delete(destFileName);
                        }
                    }
                    this.state = SaveTransactionState.Committed;
                }
                catch (Exception)
                {
                    this.state = SaveTransactionState.FailedCommit;
                    throw;
                }
            }
        }
Esempio n. 5
0
 public TestKernelTransactionHandle(KernelTransaction tx)
 {
     this._tx = Objects.requireNonNull(tx);
 }
Esempio n. 6
0
 public override bool IsUnderlyingTransaction(KernelTransaction tx)
 {
     return(this._tx == tx);
 }
 public override void BindTransactionToCurrentThread(KernelTransaction tx)
 {
     _txBridge.bindTransactionToCurrentThread(tx);
 }
Esempio n. 8
0
 internal DelegatingTransaction(KernelTransaction @internal, Locks locks)
 {
     this.Internal      = @internal;
     this.LocksConflict = locks;
 }
Esempio n. 9
0
        public virtual TransactionHooksState BeforeCommit(ReadableTransactionState state, KernelTransaction tx, StorageReader storageReader)
        {
            if (Hooks.Count == 0)
            {
                return(null);
            }

            TransactionHooksState hookState = new TransactionHooksState();

            foreach (TransactionHook hook in Hooks)
            {
                TransactionHook_Outcome outcome = hook.beforeCommit(state, tx, storageReader);
                hookState.Add(hook, outcome);
            }
            return(hookState);
        }