public void OnError(Exception cause) { if (Interlocked.Increment(ref wip) == 1) { do { if (ArbiterIsCancelled()) { return; } if (cause != null) { long r = remaining; if (r == 0) { actual.OnError(cause); return; } bool b; try { b = handler(cause); } catch (Exception ex) { actual.OnError(new AggregateException(cause, ex)); return; } if (!b) { actual.OnError(cause); return; } long p = produced; if (p != 0) { produced = 0; ArbiterProduced(p); } if (r != long.MaxValue) { remaining = r - 1; } } source.Subscribe(this); }while (Interlocked.Decrement(ref wip) != 0); } }
public void OnComplete() { if (Interlocked.Increment(ref wip) == 1) { do { if (ArbiterIsCancelled()) { return; } long r = remaining; if (r == 0) { actual.OnComplete(); return; } bool b; try { b = stop(); } catch (Exception ex) { actual.OnError(ex); return; } if (b) { actual.OnComplete(); return; } long p = produced; if (p != 0) { produced = 0; ArbiterProduced(p); } if (r != long.MaxValue) { remaining = r - 1; } source.Subscribe(this); }while (Interlocked.Decrement(ref wip) != 0); } }
public IDisposable Subscribe(ISubscriber <R> subscriber) { var upSubscriber = new LambdaSubscriber <T>( onNext: FilterComposer(subscriber), onError: subscriber.OnError, onComplete: subscriber.OnComplete, onSubscribe: (s, c) => { subscriber.OnSubscribe(s); c(); }, onRequest: this.onRequestFilter); return(upstream.Subscribe(upSubscriber)); }
private ProxySubscriber <Tinternal> SubscriberToFlow(ISubscriber <TReturn> subscriber, IFlowable <Tinternal> flow, Action onComplete) { var composed = FilterComposer(subscriber, (a, b) => MergeFilter(a, b)); var sourceSubscriber = new ProxySubscriber <Tinternal>(new LambdaSubscriber <Tinternal>( onNext: (x, c) => { composed(x); c(); }, onRequest: (r, s) => { s.Request(r); }, onComplete: onComplete)); flow.Subscribe(sourceSubscriber); return(sourceSubscriber); }
internal void Subscribe(IFlowable <T> source) { if (Interlocked.Increment(ref wip) == 1) { do { if (ArbiterIsCancelled()) { return; } if (source == null) { var fs = fallbacks; bool b; try { b = fs.MoveNext(); } catch (Exception ex) { fs.Dispose(); actual.OnError(ex); return; } if (!b) { actual.OnComplete(); return; } else { fs.Current.Subscribe(this); } } else { source.Subscribe(this); source = null; } }while (Interlocked.Decrement(ref wip) != 0); } }
internal void Subscribe(IFlowable <T> source) { if (Interlocked.Increment(ref wip) == 1) { do { if (source == null) { hasValue = true; fallback.Subscribe(this); } else { source.Subscribe(this); source = null; } }while (Interlocked.Decrement(ref wip) != 0); } }
internal void Subscribe(IFlowable <T> source) { if (Interlocked.Increment(ref wip) == 1) { do { if (ArbiterIsCancelled()) { return; } if (source == null) { var fs = fallbacks; var n = fs.Length; var i = index; if (i == n) { actual.OnComplete(); return; } else { index = i + 1; fs[i].Subscribe(this); } } else { source.Subscribe(this); source = null; } }while (Interlocked.Decrement(ref wip) != 0); } }
public static IDisposable Subscribe <TSource>(this IFlowable <TSource> inflow, Action <TSource> onNext, Action <Exception> onError = null, Action onComplete = null) { return(inflow.Subscribe(new LambdaSubscriber <TSource>((a, c) => { onNext(a); c(); }, onError, onComplete))); }