public IDisposable Run(Amb <TSource> parent) { var ls = new SingleAssignmentDisposable(); var rs = new SingleAssignmentDisposable(); var d = StableCompositeDisposable.Create(ls, rs); var gate = new object(); var lo = new AmbObserver(); lo._disposable = d; lo._target = new DecisionObserver(this, gate, AmbState.Left, ls, rs, lo); var ro = new AmbObserver(); ro._disposable = d; ro._target = new DecisionObserver(this, gate, AmbState.Right, rs, ls, ro); _choice = AmbState.Neither; ls.Disposable = parent._left.SubscribeSafe(lo); rs.Disposable = parent._right.SubscribeSafe(ro); return(d); }
public _(Amb <TSource> parent, IObserver <TSource> observer, IDisposable cancel) : base(observer, cancel) { _parent = parent; }