public void UpstreamNext(T value) { if (IsDisposed()) { return; } var o = default(IObservable <R>); try { o = mapper(value); } catch (Exception ex) { base.Dispose(); OnError(ex); return; } var inner = new InnerObserver <R>(this); observers.Offer(inner); if (!IsDisposed()) { inner.OnSubscribe(o.Subscribe(inner)); } Drain(); }
protected void UpstreamNext(IObservable <T> value) { Interlocked.Increment(ref active); var inner = new InnerObserver(this); if (Add(inner)) { inner.OnSubscribe(value.Subscribe(inner)); } }
internal void SubscribeAll(IObservable <U>[] others) { var o = observers; var n = o.Length; for (int i = 0; i < n; i++) { if (IsDisposed()) { return; } InnerObserver inner = o[i]; inner.OnSubscribe(others[i].Subscribe(o[i])); } }
public override void OnNext(T value) { if (done) { return; } var o = default(IObservable <R>); try { o = mapper(value); if (o == null) { throw new NullReferenceException("The mapper returned a null " + typeof(IObservable <R>)); } } catch (Exception ex) { OnError(ex); return; } var inner = new InnerObserver <R>(this); for (; ;) { var a = Volatile.Read(ref active); if (a == DISPOSED) { break; } if (Interlocked.CompareExchange(ref active, inner, a) == a) { a?.Dispose(); inner.OnSubscribe(o.Subscribe(inner)); break; } } }