public TccTransaction(TccTransactionData data, TccCoordinator <TContext> coordinator, TContext ctx) { // TODO: 从TransactionData中恢复数据 _context = ctx.Deserialize <TContext>(data.ContextData); _txId = data.TxId; _txState = data.TxState; _lock = null; _works = new List <TccWorkUnit <TContext> >(); _txCtx = null; _coordinator = coordinator; if (_coordinator != null) { _coordinator.NewTransaction(this); _tracing = _coordinator.Tracing; } else { _tracing = _defaultTracing; } Prepare(); foreach (var a in _works) { a.Tracing = _tracing; } }
public TccTransaction(TContext ctx, TccCoordinator <TContext> coordinator) { _context = ctx; _txId = Guid.NewGuid().ToString(); _txState = TccTransactionState.New; _lock = null; _works = new List <TccWorkUnit <TContext> >(); _txCtx = null; Prepare(); _coordinator = coordinator; if (_coordinator != null) { _coordinator.NewTransaction(this); _tracing = _coordinator.Tracing; } else { _tracing = _defaultTracing; } foreach (var a in _works) { a.Tracing = _tracing; } }
protected int AddWorkUnit(TccWorkUnit <TContext> work, params int[] prevs) { work.Tracing = _tracing; TccWorkUnit <TContext>[] prevWorks = new TccWorkUnit <TContext> [prevs.Length]; int n = 0; foreach (var i in prevs) { if (i < 0 || i >= _works.Count) { throw new InvalidDataException("Work Dependency Range Failed:" + i); } prevWorks[n++] = _works[i]; } _works.Add(work); work.PrevWorks = prevWorks; return(_works.Count - 1); }
protected int AddWorkUnit(TccWorkUnit <TContext> work) { work.Tracing = _tracing; _works.Add(work); return(_works.Count - 1); }
protected void AddLockUnit(TccWorkUnit <TContext> work) { work.Tracing = _tracing; _lock = work; }
public void AddWork(TccWorkUnit <Context> work, TccAction nextAction) { _works.Add(new ComboClass <TccWorkUnit <Context>, TccAction>(work, nextAction)); }