@SuppressWarnings("unchecked") @Override public void onComplete() { if (subscribers.get() == TERMINATED) { return; } for (PublishDisposable<T> s : subscribers.getAndSet(TERMINATED)) { s.onComplete(); } }
@SuppressWarnings("unchecked") @Override public void onError(Throwable t) { ObjectHelper.requireNonNull(t, "onError called with null. Null values are generally not allowed in 2.x operators and sources."); if (subscribers.get() == TERMINATED) { RxJavaPlugins.onError(t); return; } error = t; for (PublishDisposable<T> s : subscribers.getAndSet(TERMINATED)) { s.onError(t); } }
@Override public void onNext(T t) { ObjectHelper.requireNonNull(t, "onNext called with null. Null values are generally not allowed in 2.x operators and sources."); for (PublishDisposable<T> s : subscribers.get()) { s.onNext(t); } }
@Override public void subscribeActual(Observer<? super T> t) { PublishDisposable<T> ps = new PublishDisposable<T>(t, this); t.onSubscribe(ps); if (add(ps)) { // if cancellation happened while a successful add, the remove() didn't work // so we need to do it again if (ps.isDisposed()) { remove(ps); } } else { Throwable ex = error; if (ex != null) { t.onError(ex); } else { t.onComplete(); } } }
@Override public boolean isDisposed() { return get(); } }
public void onNext(T t) { if (!get()) { actual.onNext(t); } }
@Override public void dispose() { if (compareAndSet(false, true)) { parent.remove(this); } }
public void onComplete() { if (!get()) { actual.onComplete(); } }
public void onError(Throwable t) { if (get()) { RxJavaPlugins.onError(t); } else { actual.onError(t); } }
@Override protected void subscribeActual(Observer<? super T> t) { PublishDisposable<T> ps = new PublishDisposable<T>(t, this); t.onSubscribe(ps); if (add(ps)) { // if cancellation happened while a successful add, the remove() didn't work // so we need to do it again if (ps.isDisposed()) { remove(ps); } } else { Throwable ex = error; if (ex != null) { t.onError(ex); } else { t.onComplete(); } } }
@SuppressWarnings("unchecked") @Override public void onError(Throwable t) { ObjectHelper.requireNonNull(t, "onError called with null. Null values are generally not allowed in 2.x operators and sources."); if (subscribers.get() == TERMINATED) { RxJavaPlugins.onError(t); return; } error = t; for (PublishDisposable<T> pd : subscribers.getAndSet(TERMINATED)) { pd.onError(t); } }
@Override public void dispose() { if (compareAndSet(false, true)) { parent.remove(this); } }
public void onNext(T t) { if (!get()) { downstream.onNext(t); } }
@SuppressWarnings("unchecked") @Override public void onComplete() { if (subscribers.get() == TERMINATED) { return; } for (PublishDisposable<T> pd : subscribers.getAndSet(TERMINATED)) { pd.onComplete(); } }
public void onError(Throwable t) { if (get()) { RxJavaPlugins.onError(t); } else { downstream.onError(t); } }
@Override public void onNext(T t) { ObjectHelper.requireNonNull(t, "onNext called with null. Null values are generally not allowed in 2.x operators and sources."); for (PublishDisposable<T> pd : subscribers.get()) { pd.onNext(t); } }
@Override public boolean isDisposed() { return get(); } }
public void onComplete() { if (!get()) { downstream.onComplete(); } }