use of io.reactivex.rxjava3.disposables.CompositeDisposable in project RxJava by ReactiveX.
the class ScheduledRunnableTest method disposeRun.
@Test
public void disposeRun() {
CompositeDisposable set = new CompositeDisposable();
ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, set);
set.add(run);
assertFalse(run.isDisposed());
run.dispose();
run.dispose();
assertTrue(run.isDisposed());
}
use of io.reactivex.rxjava3.disposables.CompositeDisposable in project RxJava by ReactiveX.
the class ScheduledRunnableTest method disposeRace.
@Test
public void disposeRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
CompositeDisposable set = new CompositeDisposable();
final ScheduledRunnable run = new ScheduledRunnable(Functions.EMPTY_RUNNABLE, set);
set.add(run);
Runnable r1 = new Runnable() {
@Override
public void run() {
run.dispose();
}
};
TestHelper.race(r1, r1);
assertEquals(0, set.size());
}
}
use of io.reactivex.rxjava3.disposables.CompositeDisposable in project Signal-Android by signalapp.
the class SignalWebSocket method getUnidentifiedWebSocket.
private synchronized WebSocketConnection getUnidentifiedWebSocket() throws WebSocketUnavailableException {
if (!canConnect) {
throw new WebSocketUnavailableException();
}
if (unidentifiedWebSocket == null || unidentifiedWebSocket.isDead()) {
unidentifiedWebSocketStateDisposable.dispose();
unidentifiedWebSocket = webSocketFactory.createUnidentifiedWebSocket();
unidentifiedWebSocketStateDisposable = new CompositeDisposable();
Disposable state = unidentifiedWebSocket.connect().subscribeOn(Schedulers.computation()).observeOn(Schedulers.computation()).subscribe(unidentifiedWebSocketState::onNext);
unidentifiedWebSocketStateDisposable.add(state);
}
return unidentifiedWebSocket;
}
use of io.reactivex.rxjava3.disposables.CompositeDisposable in project RxJava by ReactiveX.
the class IoSchedulerInternalTest method noExpiredWorker.
@Test
public void noExpiredWorker() {
ConcurrentLinkedQueue<ThreadWorker> expire = new ConcurrentLinkedQueue<>();
CompositeDisposable cd = new CompositeDisposable();
ThreadWorker tw = new ThreadWorker(new RxThreadFactory("IoExpiryTest"));
tw.setExpirationTime(System.nanoTime() + 10_000_000_000L);
try {
expire.add(tw);
cd.add(tw);
CachedWorkerPool.evictExpiredWorkers(expire, cd);
assertFalse(tw.isDisposed());
assertFalse(expire.isEmpty());
} finally {
tw.dispose();
}
}
use of io.reactivex.rxjava3.disposables.CompositeDisposable in project RxJava by ReactiveX.
the class IoSchedulerInternalTest method expiredWorkerRemoved.
@Test
public void expiredWorkerRemoved() {
ConcurrentLinkedQueue<ThreadWorker> expire = new ConcurrentLinkedQueue<>();
CompositeDisposable cd = new CompositeDisposable();
ThreadWorker tw = new ThreadWorker(new RxThreadFactory("IoExpiryTest"));
try {
expire.add(tw);
cd.add(tw);
CachedWorkerPool.evictExpiredWorkers(expire, cd);
assertTrue(tw.isDisposed());
assertTrue(expire.isEmpty());
} finally {
tw.dispose();
}
}
Aggregations