SwitchMapObserver(Observer<? super R> actual, Function<? super T, ? extends ObservableSource<? extends R>> mapper, int bufferSize, boolean delayErrors) { this.actual = actual; this.mapper = mapper; this.bufferSize = bufferSize; this.delayErrors = delayErrors; this.errors = new AtomicThrowable(); }
/** * Emits the given exception if possible or adds it to the given error container to * be emitted by a concurrent onNext if one is running. * Undeliverable exceptions are sent to the RxJavaCommonPlugins.onError. * @param observer the target Subscriber to emit to * @param ex the Throwable to emit * @param wip the serialization work-in-progress counter/indicator * @param error the holder of Throwables */ public static void onError(Observer<?> observer, Throwable ex, AtomicInteger wip, AtomicThrowable error) { if (error.addThrowable(ex)) { if (wip.getAndIncrement() == 0) { observer.onError(error.terminate()); } } else { RxJavaCommonPlugins.onError(ex); } }
@Override public void onError(Throwable e) { if (errors.compareAndSet(null, e)) { cancelAll(); drain(); } else { if (e != errors.get()) { RxJavaCommonPlugins.onError(e); } } }
public boolean isTerminated() { return get() == ExceptionHelper.TERMINATED; } }
@Override void onError(Throwable e) { errors.addThrowable(e); done.decrementAndGet(); drain(); }
void tryTerminate() { if (wip.decrementAndGet() == 0) { Throwable ex = error.terminate(); if (ex == null) { actual.onComplete(); } else { actual.onError(ex); } } } }
@Test public void isTerminated() { AtomicThrowable ex = new AtomicThrowable(); assertFalse(ex.isTerminated()); assertNull(ex.terminate()); assertTrue(ex.isTerminated()); } }
cancelAll(); Throwable mbe = new MissingBackpressureException("Queue full?!"); if (errors.compareAndSet(null, mbe)) { actual.onError(mbe); } else {
public boolean isTerminated() { return get() == ExceptionHelper.TERMINATED; } }
void onError(Throwable e) { if (!errors.addThrowable(e)) { RxJavaCommonPlugins.onError(e); } } }
void tryTerminate() { if (wip.decrementAndGet() == 0) { Throwable ex = error.terminate(); if (ex == null) { actual.onComplete(); } else { actual.onError(ex); } } } }
SwitchMapObserver(Observer<? super R> actual, Function<? super T, ? extends ObservableSource<? extends R>> mapper, int bufferSize, boolean delayErrors) { this.actual = actual; this.mapper = mapper; this.bufferSize = bufferSize; this.delayErrors = delayErrors; this.errors = new AtomicThrowable(); }
public boolean isTerminated() { return get() == ExceptionHelper.TERMINATED; } }
@Override public void onError(Throwable t) { if (errors.addThrowable(t)) { inner.cancel(); if (getAndIncrement() == 0) { actual.onError(errors.terminate()); } } else { RxJavaCommonPlugins.onError(t); } }
void onError(Throwable e) { if (!errors.addThrowable(e)) { RxJavaCommonPlugins.onError(e); } } }
void disposeAll() { InnerSubscriber<?, ?>[] a = subscribers.get(); if (a != CANCELLED) { a = subscribers.getAndSet(CANCELLED); if (a != CANCELLED) { for (InnerSubscriber<?, ?> inner : a) { inner.dispose(); } Throwable ex = errs.terminate(); if (ex != null && ex != ExceptionHelper.TERMINATED) { RxJavaCommonPlugins.onError(ex); } } } }
ConcatMapEagerMainObserver(Observer<? super R> actual, Function<? super T, ? extends ObservableSource<? extends R>> mapper, int maxConcurrency, int prefetch, ErrorMode errorMode) { this.actual = actual; this.mapper = mapper; this.maxConcurrency = maxConcurrency; this.prefetch = prefetch; this.errorMode = errorMode; this.error = new AtomicThrowable(); this.observers = new ArrayDeque<InnerQueuedObserver<R>>(); }