use of io.reactivex.rxjava3.core.Scheduler in project RxJava by ReactiveX.
the class ParallelRunOn method subscribe.
@Override
public void subscribe(Subscriber<? super T>[] subscribers) {
subscribers = RxJavaPlugins.onSubscribe(this, subscribers);
if (!validate(subscribers)) {
return;
}
int n = subscribers.length;
@SuppressWarnings("unchecked") final Subscriber<T>[] parents = new Subscriber[n];
if (scheduler instanceof SchedulerMultiWorkerSupport) {
SchedulerMultiWorkerSupport multiworker = (SchedulerMultiWorkerSupport) scheduler;
multiworker.createWorkers(n, new MultiWorkerCallback(subscribers, parents));
} else {
for (int i = 0; i < n; i++) {
createSubscriber(i, subscribers, parents, scheduler.createWorker());
}
}
source.subscribe(parents);
}
use of io.reactivex.rxjava3.core.Scheduler in project RxJava by ReactiveX.
the class ConnectableObservable method connect.
/**
* Instructs the {@code ConnectableObservable} to begin emitting the items from its underlying
* {@link Observable} to its {@link Observer}s.
* <p>
* To disconnect from a synchronous source, use the {@link #connect(Consumer)} method.
* <dl>
* <dt><b>Scheduler:</b></dt>
* <dd>The behavior is determined by the implementor of this abstract class.</dd>
* </dl>
*
* @return the {@link Disposable} representing the connection
* @see <a href="http://reactivex.io/documentation/operators/connect.html">ReactiveX documentation: Connect</a>
*/
@NonNull
@SchedulerSupport(SchedulerSupport.NONE)
public final Disposable connect() {
ConnectConsumer cc = new ConnectConsumer();
connect(cc);
return cc.disposable;
}
use of io.reactivex.rxjava3.core.Scheduler in project RxJava by ReactiveX.
the class CompletableTimeoutTest method errorTimeoutRace.
@Test
public void errorTimeoutRace() {
for (int i = 0; i < TestHelper.RACE_DEFAULT_LOOPS; i++) {
List<Throwable> errors = TestHelper.trackPluginErrors();
try {
final TestScheduler scheduler = new TestScheduler();
final PublishSubject<Integer> ps = PublishSubject.create();
TestObserverEx<Void> to = ps.ignoreElements().timeout(1, TimeUnit.MILLISECONDS, scheduler, Completable.complete()).to(TestHelper.<Void>testConsumer());
final TestException ex = new TestException();
Runnable r1 = new Runnable() {
@Override
public void run() {
ps.onError(ex);
}
};
Runnable r2 = new Runnable() {
@Override
public void run() {
scheduler.advanceTimeBy(1, TimeUnit.MILLISECONDS);
}
};
TestHelper.race(r1, r2);
to.assertTerminated();
if (!errors.isEmpty()) {
TestHelper.assertUndeliverable(errors, 0, TestException.class);
}
} finally {
RxJavaPlugins.reset();
}
}
}
use of io.reactivex.rxjava3.core.Scheduler in project RxJava by ReactiveX.
the class BlockingFlowableLatestTest method hasNextThrows.
@Test(expected = RuntimeException.class)
public void hasNextThrows() {
TestScheduler scheduler = new TestScheduler();
Flowable<Long> source = Flowable.<Long>error(new RuntimeException("Forced failure!")).subscribeOn(scheduler);
Iterable<Long> iter = source.blockingLatest();
Iterator<Long> it = iter.iterator();
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
it.hasNext();
}
use of io.reactivex.rxjava3.core.Scheduler in project RxJava by ReactiveX.
the class BlockingFlowableLatestTest method simple.
@Test
public void simple() {
TestScheduler scheduler = new TestScheduler();
Flowable<Long> source = Flowable.interval(1, TimeUnit.SECONDS, scheduler).take(10);
Iterable<Long> iter = source.blockingLatest();
Iterator<Long> it = iter.iterator();
// which onComplete will overwrite the previous value
for (int i = 0; i < 9; i++) {
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
Assert.assertTrue(it.hasNext());
Assert.assertEquals(Long.valueOf(i), it.next());
}
scheduler.advanceTimeBy(1, TimeUnit.SECONDS);
Assert.assertFalse(it.hasNext());
}
Aggregations