void scheduleTimeout(long idx) { Disposable d = timer; if (d != null) { d.dispose(); } if (TIMER.compareAndSet(this, d, NEW_TIMER)) { d = worker.schedule( () -> { if (idx == index) { done = true; s.dispose(); disposeTimer(); worker.dispose(); if (other == null) { actual.onError(new TimeoutException()); } else { subscribeNext(); } } }, timeout, unit); if (!TIMER.compareAndSet(this, NEW_TIMER, d)) { d.dispose(); } } }
@Override public void onComplete() { if (done) { return; } done = true; worker.dispose(); disposeTimer(); arbiter.onComplete(s); }
@Override public void onError(Throwable t) { if (done) { RxJavaPlugins.onError(t); return; } done = true; worker.dispose(); disposeTimer(); arbiter.onError(t, s); }
@Override public void dispose() { worker.dispose(); disposeTimer(); }