use of io.reactivex.rxjava3.disposables.Disposable in project redisson by redisson.
the class RedissonRemoteServiceTest method testCancelReactive.
@Test
public void testCancelReactive() throws InterruptedException {
RedissonReactiveClient r1 = Redisson.create(createConfig()).reactive();
AtomicInteger iterations = new AtomicInteger();
ExecutorService executor = Executors.newSingleThreadExecutor();
r1.getKeys().flushall();
r1.getRemoteService().register(RemoteInterface.class, new RemoteImpl(iterations), 1, executor);
RedissonReactiveClient r2 = Redisson.create(createConfig()).reactive();
RemoteInterfaceReactive ri = r2.getRemoteService().get(RemoteInterfaceReactive.class);
Mono<Void> f = ri.cancelMethod();
Disposable t = f.doOnSubscribe(s -> s.request(1)).subscribe();
Thread.sleep(500);
t.dispose();
executor.shutdown();
r1.shutdown();
r2.shutdown();
assertThat(iterations.get()).isLessThan(Integer.MAX_VALUE / 2);
assertThat(executor.awaitTermination(2, TimeUnit.SECONDS)).isTrue();
}
use of io.reactivex.rxjava3.disposables.Disposable in project Tusky by Vavassor.
the class NotificationsFragment method sendFetchNotificationsRequest.
private void sendFetchNotificationsRequest(String fromId, String uptoId, final FetchEnd fetchEnd, final int pos) {
/* If there is a fetch already ongoing, record however many fetches are requested and
* fulfill them after it's complete. */
if (fetchEnd == FetchEnd.TOP && topLoading) {
return;
}
if (fetchEnd == FetchEnd.BOTTOM && bottomLoading) {
return;
}
if (fetchEnd == FetchEnd.TOP) {
topLoading = true;
}
if (fetchEnd == FetchEnd.BOTTOM) {
bottomLoading = true;
}
Disposable notificationCall = mastodonApi.notifications(fromId, uptoId, LOAD_AT_ONCE, showNotificationsFilter ? notificationFilter : null).observeOn(AndroidSchedulers.mainThread()).to(autoDisposable(from(this, Lifecycle.Event.ON_DESTROY))).subscribe(response -> {
if (response.isSuccessful()) {
String linkHeader = response.headers().get("Link");
onFetchNotificationsSuccess(response.body(), linkHeader, fetchEnd, pos);
} else {
onFetchNotificationsFailure(new Exception(response.message()), fetchEnd, pos);
}
}, throwable -> onFetchNotificationsFailure(throwable, fetchEnd, pos));
disposables.add(notificationCall);
}
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);
}
}
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);
}
}
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);
}
Aggregations