Search in sources :

Example 11 with Disposable

use of io.reactivex.rxjava3.disposables.Disposable in project Signal-Android by WhisperSystems.

the class SignalWebSocket method getWebSocket.

private synchronized WebSocketConnection getWebSocket() throws WebSocketUnavailableException {
    if (!canConnect) {
        throw new WebSocketUnavailableException();
    }
    if (webSocket == null || webSocket.isDead()) {
        webSocketStateDisposable.dispose();
        webSocket = webSocketFactory.createWebSocket();
        webSocketStateDisposable = new CompositeDisposable();
        Disposable state = webSocket.connect().subscribeOn(Schedulers.computation()).observeOn(Schedulers.computation()).subscribe(webSocketState::onNext);
        webSocketStateDisposable.add(state);
    }
    return webSocket;
}
Also used : CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable) Disposable(io.reactivex.rxjava3.disposables.Disposable) WebSocketUnavailableException(org.whispersystems.signalservice.api.websocket.WebSocketUnavailableException) CompositeDisposable(io.reactivex.rxjava3.disposables.CompositeDisposable)

Example 12 with Disposable

use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.

the class FlowableInterval method subscribeActual.

@Override
public void subscribeActual(Subscriber<? super Long> s) {
    IntervalSubscriber is = new IntervalSubscriber(s);
    s.onSubscribe(is);
    Scheduler sch = scheduler;
    if (sch instanceof TrampolineScheduler) {
        Worker worker = sch.createWorker();
        is.setResource(worker);
        worker.schedulePeriodically(is, initialDelay, period, unit);
    } else {
        Disposable d = sch.schedulePeriodicallyDirect(is, initialDelay, period, unit);
        is.setResource(d);
    }
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable) TrampolineScheduler(io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler) Worker(io.reactivex.rxjava3.core.Scheduler.Worker) TrampolineScheduler(io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler)

Example 13 with Disposable

use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.

the class ObservableIntervalRange method subscribeActual.

@Override
public void subscribeActual(Observer<? super Long> observer) {
    IntervalRangeObserver is = new IntervalRangeObserver(observer, start, end);
    observer.onSubscribe(is);
    Scheduler sch = scheduler;
    if (sch instanceof TrampolineScheduler) {
        Worker worker = sch.createWorker();
        is.setResource(worker);
        worker.schedulePeriodically(is, initialDelay, period, unit);
    } else {
        Disposable d = sch.schedulePeriodicallyDirect(is, initialDelay, period, unit);
        is.setResource(d);
    }
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable) TrampolineScheduler(io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler) Worker(io.reactivex.rxjava3.core.Scheduler.Worker) TrampolineScheduler(io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler)

Example 14 with Disposable

use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.

the class FlowableTimer method subscribeActual.

@Override
public void subscribeActual(Subscriber<? super Long> s) {
    TimerSubscriber ios = new TimerSubscriber(s);
    s.onSubscribe(ios);
    Disposable d = scheduler.scheduleDirect(ios, delay, unit);
    ios.setResource(d);
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable)

Example 15 with Disposable

use of io.reactivex.rxjava3.disposables.Disposable in project RxJava by ReactiveX.

the class FlowableRefCount method timeout.

void timeout(RefConnection rc) {
    synchronized (this) {
        if (rc.subscriberCount == 0 && rc == connection) {
            connection = null;
            Disposable connectionObject = rc.get();
            DisposableHelper.dispose(rc);
            if (connectionObject == null) {
                rc.disconnectedEarly = true;
            } else {
                source.reset();
            }
        }
    }
}
Also used : Disposable(io.reactivex.rxjava3.disposables.Disposable)

Aggregations

Test (org.junit.Test)251 Disposable (io.reactivex.rxjava3.disposables.Disposable)236 TestException (io.reactivex.rxjava3.exceptions.TestException)74 RxJavaTest (io.reactivex.rxjava3.core.RxJavaTest)56 IOException (java.io.IOException)38 Scheduler (io.reactivex.rxjava3.core.Scheduler)36 EmptyDisposable (io.reactivex.rxjava3.internal.disposables.EmptyDisposable)35 Worker (io.reactivex.rxjava3.core.Scheduler.Worker)34 BooleanSubscription (io.reactivex.rxjava3.internal.subscriptions.BooleanSubscription)32 TestSubscriber (io.reactivex.rxjava3.subscribers.TestSubscriber)22 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)22 TestObserver (io.reactivex.rxjava3.observers.TestObserver)18 SequentialDisposable (io.reactivex.rxjava3.internal.disposables.SequentialDisposable)15 QueueDisposable (io.reactivex.rxjava3.operators.QueueDisposable)13 CountingRunnable (io.reactivex.rxjava3.android.testutil.CountingRunnable)10 TrampolineScheduler (io.reactivex.rxjava3.internal.schedulers.TrampolineScheduler)9 LifecycleDisposable (org.thoughtcrime.securesms.util.LifecycleDisposable)8 Observable (io.reactivex.rxjava3.core.Observable)6 Observer (io.reactivex.rxjava3.core.Observer)6 ScalarDisposable (io.reactivex.rxjava3.internal.operators.observable.ObservableScalarXMap.ScalarDisposable)6