io.reactivex.internal.disposables.DisposableHelper Java Examples
The following examples show how to use
io.reactivex.internal.disposables.DisposableHelper.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlowableInsertTimeout.java From rxjava2-extras with Apache License 2.0 | 6 votes |
@Override public void onNext(final T t) { if (finished) { return; } queue.offer(t); final long waitTime; try { waitTime = timeout.apply(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); // we cancel upstream ourselves because the // error did not originate from source upstream.cancel(); onError(e); return; } TimeoutAction<T> action = new TimeoutAction<T>(this, t); Disposable d = worker.schedule(action, waitTime, unit); DisposableHelper.set(scheduled, d); drain(); }
Example #2
Source File: FlowableInsertMaybe.java From rxjava2-extras with Apache License 2.0 | 6 votes |
@Override public void onNext(T t) { if (finished) { return; } queue.offer(t); Maybe<? extends T> maybe; try { maybe = valueToInsert.apply(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); // we cancel upstream ourselves because the // error did not originate from source upstream.cancel(); onError(e); return; } ValueToInsertObserver<T> o = new ValueToInsertObserver<T>(this); if (DisposableHelper.set(valueToInsertObserver, o)) { // note that at this point we have to cover o being disposed // from another thread so the Observer class needs // to handle dispose being called before/during onSubscribe maybe.subscribe(o); } drain(); }
Example #3
Source File: FlowableInsertMaybe.java From rxjava2-extras with Apache License 2.0 | 6 votes |
@Override public void cancel() { if (!cancelled) { cancelled = true; upstream.cancel(); DisposableHelper.dispose(valueToInsertObserver); if (getAndIncrement() == 0) { // use the same access control to queue as drain method // because `clear` just calls `queue.poll()` repeatedly till nothing left on the // queue (ignoring the dequeued items). // // this is best endeavours, there still exists a race with onNext and drain // where items could be left on the queue after cancel queue.clear(); } } }
Example #4
Source File: LifeSingleObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onError(Throwable t) { if (isDisposed()) { RxJavaPlugins.onError(t); return; } lazySet(DisposableHelper.DISPOSED); try { removeObserver(); downstream.onError(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); RxJavaPlugins.onError(new CompositeException(t, e)); } }
Example #5
Source File: WriteStreamObserverImpl.java From vertx-rx with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable disposable) { Objects.requireNonNull(disposable, "disposable"); if (!setDisposable(disposable)) { disposable.dispose(); DisposableHelper.reportDisposableSet(); return; } writeStream.exceptionHandler(t -> { if (!setDone()) { RxJavaPlugins.onError(t); return; } getDisposable().dispose(); Consumer<? super Throwable> c; synchronized (this) { c = this.writeStreamExceptionHandler; } if (c != null) { try { c.accept(t); } catch (Exception e) { RxJavaPlugins.onError(t); } } }); }
Example #6
Source File: CompletableOnAssembly.java From RxJava2Debug with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (DisposableHelper.validate(this.d, d)) { this.d = d; actual.onSubscribe(this); } }
Example #7
Source File: MaybeOnAssembly.java From RxJava2Debug with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (DisposableHelper.validate(this.d, d)) { this.d = d; actual.onSubscribe(this); } }
Example #8
Source File: SingleOnAssembly.java From RxJava2Debug with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (DisposableHelper.validate(this.d, d)) { this.d = d; actual.onSubscribe(this); } }
Example #9
Source File: FlowableInsertMaybe.java From rxjava2-extras with Apache License 2.0 | 5 votes |
@Override public void onError(Throwable e) { if (finished) { RxJavaPlugins.onError(e); return; } finished = true; if (error.compareAndSet(null, e)) { DisposableHelper.dispose(valueToInsertObserver); done = true; drain(); } else { RxJavaPlugins.onError(e); } }
Example #10
Source File: FlowableInsertMaybe.java From rxjava2-extras with Apache License 2.0 | 5 votes |
@Override public void onComplete() { if (finished) { return; } finished = true; DisposableHelper.dispose(valueToInsertObserver); done = true; drain(); }
Example #11
Source File: FlowableInsertMaybe.java From rxjava2-extras with Apache License 2.0 | 5 votes |
void insertError(Throwable e) { if (error.compareAndSet(null, e)) { upstream.cancel(); DisposableHelper.dispose(valueToInsertObserver); done = true; drain(); } else { RxJavaPlugins.onError(e); } }
Example #12
Source File: FlowableInsertMaybe.java From rxjava2-extras with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable upstream) { // an AtomicReference is used to hold the upstream Disposable // because this Observer can be disposed before onSubscribe // is called (contrary to the normal contract). DisposableHelper.setOnce(this, upstream); }
Example #13
Source File: SingleFlatMapIterableFlowable.java From akarnokd-misc with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (DisposableHelper.validate(this.d, d)) { this.d = d; actual.onSubscribe(this); } }
Example #14
Source File: SingleFlatMapIterableObservable.java From akarnokd-misc with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (DisposableHelper.validate(this.d, d)) { this.d = d; actual.onSubscribe(this); } }
Example #15
Source File: RequestContextSingleObserver.java From armeria with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (!DisposableHelper.validate(disposable, d)) { return; } disposable = d; try (SafeCloseable ignored = assemblyContext.push()) { actual.onSubscribe(this); } }
Example #16
Source File: RequestContextMaybeObserver.java From armeria with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (!DisposableHelper.validate(disposable, d)) { return; } disposable = d; try (SafeCloseable ignored = assemblyContext.push()) { actual.onSubscribe(this); } }
Example #17
Source File: RequestContextCompletableObserver.java From armeria with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (!DisposableHelper.validate(disposable, d)) { return; } disposable = d; try (SafeCloseable ignored = assemblyContext.push()) { actual.onSubscribe(this); } }
Example #18
Source File: LifeObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (DisposableHelper.setOnce(this, d)) { try { addObserver(); downstream.onSubscribe(d); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); d.dispose(); onError(ex); } } }
Example #19
Source File: LifeObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onError(Throwable t) { if (isDisposed()) { RxJavaPlugins.onError(t); return; } lazySet(DisposableHelper.DISPOSED); try { removeObserver(); downstream.onError(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); RxJavaPlugins.onError(new CompositeException(t, e)); } }
Example #20
Source File: LifeMaybeObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onSuccess(T t) { if (isDisposed()) return; lazySet(DisposableHelper.DISPOSED); try { removeObserver(); downstream.onSuccess(t); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); RxJavaPlugins.onError(ex); } }
Example #21
Source File: LifeMaybeObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (DisposableHelper.setOnce(this, d)) { try { addObserver(); downstream.onSubscribe(d); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); d.dispose(); onError(ex); } } }
Example #22
Source File: LifeSingleObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onSuccess(T t) { if (isDisposed()) return; lazySet(DisposableHelper.DISPOSED); try { removeObserver(); downstream.onSuccess(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); RxJavaPlugins.onError(e); } }
Example #23
Source File: LifeMaybeObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onError(Throwable t) { if (isDisposed()) { RxJavaPlugins.onError(t); return; } lazySet(DisposableHelper.DISPOSED); try { removeObserver(); downstream.onError(t); } catch (Throwable e) { Exceptions.throwIfFatal(e); RxJavaPlugins.onError(new CompositeException(t, e)); } }
Example #24
Source File: LifeMaybeObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onComplete() { if (isDisposed()) return; lazySet(DisposableHelper.DISPOSED); try { removeObserver(); downstream.onComplete(); } catch (Throwable e) { Exceptions.throwIfFatal(e); RxJavaPlugins.onError(e); } }
Example #25
Source File: LifeCompletableObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (DisposableHelper.setOnce(this, d)) { try { addObserver(); downstream.onSubscribe(d); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); d.dispose(); onError(ex); } } }
Example #26
Source File: LifeCompletableObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onError(Throwable t) { if (isDisposed()) return; lazySet(DisposableHelper.DISPOSED); try { removeObserver(); downstream.onError(t); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); RxJavaPlugins.onError(ex); } }
Example #27
Source File: LifeCompletableObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onComplete() { if (isDisposed()) return; lazySet(DisposableHelper.DISPOSED); try { removeObserver(); downstream.onComplete(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); RxJavaPlugins.onError(ex); } }
Example #28
Source File: LifeSingleObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onSubscribe(Disposable d) { if (DisposableHelper.setOnce(this, d)) { try { addObserver(); downstream.onSubscribe(d); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); d.dispose(); onError(ex); } } }
Example #29
Source File: LifeObserver.java From rxjava-RxLife with Apache License 2.0 | 5 votes |
@Override public void onComplete() { if (isDisposed()) return; lazySet(DisposableHelper.DISPOSED); try { removeObserver(); downstream.onComplete(); } catch (Throwable e) { Exceptions.throwIfFatal(e); RxJavaPlugins.onError(e); } }
Example #30
Source File: AbstractDisposable.java From resilience4j with Apache License 2.0 | 4 votes |
@Override public boolean isDisposed() { return DisposableHelper.isDisposed(subscription.get()); }