public void Run(IEnumerable <IObservable <TSource> > sources) { var srcs = sources.ToArray(); var N = srcs.Length; _queues = new Queue <TSource> [N]; for (var i = 0; i < N; i++) { _queues[i] = new Queue <TSource>(); } _isDone = new bool[N]; var subscriptions = new IDisposable[N]; if (Interlocked.CompareExchange(ref _subscriptions, subscriptions, null) == null) { for (var i = 0; i < N; i++) { var o = new SourceObserver(this, i); Disposable.SetSingle(ref subscriptions[i], srcs[i].SubscribeSafe(o)); } } }
public void Run(IEnumerable <IObservable <TSource> > sources) { var srcs = sources.ToArray(); var N = srcs.Length; _hasValue = new bool[N]; _hasValueAll = false; _values = new TSource[N]; _isDone = new bool[N]; _subscriptions = new IDisposable[N]; for (var i = 0; i < N; i++) { var j = i; var o = new SourceObserver(this, j); _subscriptions[j] = o; o.SetResource(srcs[j].SubscribeSafe(o)); } SetUpstream(StableCompositeDisposable.CreateTrusted(_subscriptions)); }
public IDisposable Run(SkipUntil <TSource, TOther> parent) { var sourceObserver = new SourceObserver(this); var otherObserver = new OtherObserver(this, sourceObserver); var otherSubscription = parent._other.SubscribeSafe(otherObserver); var sourceSubscription = parent._source.SubscribeSafe(sourceObserver); sourceObserver.Disposable = sourceSubscription; otherObserver.Disposable = otherSubscription; return(StableCompositeDisposable.Create( sourceSubscription, otherSubscription )); }
public IDisposable Run(TakeUntil <TSource, TOther> parent) { var sourceObserver = new SourceObserver(this); var otherObserver = new OtherObserver(this, sourceObserver); // COMPAT - Order of Subscribe calls per v1.0.10621 var otherSubscription = parent._other.SubscribeSafe(otherObserver); otherObserver.Disposable = otherSubscription; var sourceSubscription = parent._source.SubscribeSafe(sourceObserver); return(StableCompositeDisposable.Create( otherSubscription, sourceSubscription )); }
public IDisposable Run() { var srcs = _parent._sources.ToArray(); var N = srcs.Length; _queues = new Queue <TSource> [N]; for (int i = 0; i < N; i++) { _queues[i] = new Queue <TSource>(); } _isDone = new bool[N]; _subscriptions = new SingleAssignmentDisposable[N]; _gate = new object(); for (int i = 0; i < N; i++) { var j = i; var d = new SingleAssignmentDisposable(); _subscriptions[j] = d; var o = new SourceObserver(this, j); d.Disposable = srcs[j].SubscribeSafe(o); } return(new CompositeDisposable(_subscriptions) { Disposable.Create(() => { foreach (var q in _queues) { q.Clear(); } }) }); }
public OtherObserver(_ parent, SourceObserver sourceObserver) { _parent = parent; _sourceObserver = sourceObserver; _subscription = new SingleAssignmentDisposable(); }