@Override protected Scheduler getScheduler() { return Schedulers.trampoline(); }
@Override protected Scheduler getScheduler() { return Schedulers.trampoline(); }
@Override public void run() { String msg = key + ".1"; workDone.add(msg); System.out.println(msg); Worker worker3 = Schedulers.trampoline().createWorker(); worker3.schedule(createPrintAction(key + ".B.1", workDone)); worker3.schedule(createPrintAction(key + ".B.2", workDone)); }
@Override public void run() { String msg = key + ".1"; workDone.add(msg); System.out.println(msg); Worker worker3 = Schedulers.trampoline().createWorker(); worker3.schedule(createPrintAction(key + ".B.1", workDone)); worker3.schedule(createPrintAction(key + ".B.2", workDone)); }
/** * Shuts down the standard Schedulers. * <p>The operation is idempotent and thread-safe. */ public static void shutdown() { computation().shutdown(); io().shutdown(); newThread().shutdown(); single().shutdown(); trampoline().shutdown(); SchedulerPoolFactory.shutdown(); }
/** * Shuts down the standard Schedulers. * <p>The operation is idempotent and thread-safe. */ public static void shutdown() { computation().shutdown(); io().shutdown(); newThread().shutdown(); single().shutdown(); trampoline().shutdown(); SchedulerPoolFactory.shutdown(); }
/** * Starts the standard Schedulers. * <p>The operation is idempotent and thread-safe. */ public static void start() { computation().start(); io().start(); newThread().start(); single().start(); trampoline().start(); SchedulerPoolFactory.start(); }
/** * Shuts down the standard Schedulers. * <p>The operation is idempotent and thread-safe. */ public static void shutdown() { computation().shutdown(); io().shutdown(); newThread().shutdown(); single().shutdown(); trampoline().shutdown(); SchedulerPoolFactory.shutdown(); }
/** * Starts the standard Schedulers. * <p>The operation is idempotent and thread-safe. */ public static void start() { computation().start(); io().start(); newThread().start(); single().start(); trampoline().start(); SchedulerPoolFactory.start(); }
/** * Starts the standard Schedulers. * <p>The operation is idempotent and thread-safe. */ public static void start() { computation().start(); io().start(); newThread().start(); single().start(); trampoline().start(); SchedulerPoolFactory.start(); }
@Test public void trampolineScheduler() { Observable.just(1) .observeOn(Schedulers.trampoline()) .test() .assertResult(1); }
@Test(timeout = 2000) public void cancel() { Flowable.interval(1, TimeUnit.MILLISECONDS, Schedulers.trampoline()) .take(10) .test() .assertResult(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L); } }
@Test public void replaySelectorReturnsNullScheduled() { Observable.just(1) .replay(new Function<Observable<Integer>, Observable<Object>>() { @Override public Observable<Object> apply(Observable<Integer> v) throws Exception { return null; } }, Schedulers.trampoline()) .test() .assertFailureAndMessage(NullPointerException.class, "The selector returned a null ObservableSource"); }
@Test public void delayCustomScheduler() { Completable.complete() .delay(100, TimeUnit.MILLISECONDS, Schedulers.trampoline()) .test() .assertResult(); }
@Test public void trampolineScheduler() { Flowable.just(1) .observeOn(Schedulers.trampoline()) .test() .assertResult(1); }
@Test(timeout = 2000) public void cancel() { Observable.intervalRange(0, 20, 1, 1, TimeUnit.MILLISECONDS, Schedulers.trampoline()) .take(10) .test() .assertResult(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L); } }
@Test(timeout = 2000) public void cancel() { Flowable.intervalRange(0, 20, 1, 1, TimeUnit.MILLISECONDS, Schedulers.trampoline()) .take(10) .test() .assertResult(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L); } }
@Test(timeout = 2000) public void cancel() { Observable.interval(1, TimeUnit.MILLISECONDS, Schedulers.trampoline()) .take(10) .test() .assertResult(0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L); } }
@Test public void replaySelectorReturnsNull() { Flowable.just(1) .replay(new Function<Flowable<Integer>, Publisher<Object>>() { @Override public Publisher<Object> apply(Flowable<Integer> v) throws Exception { return null; } }, Schedulers.trampoline()) .test() .assertFailureAndMessage(NullPointerException.class, "The selector returned a null Publisher"); } }
@Test public void dispose() { Worker w = Schedulers.trampoline().createWorker(); assertFalse(w.isDisposed()); w.dispose(); assertTrue(w.isDisposed()); assertEquals(TrampolineScheduler.DONE, w.schedule(Functions.EMPTY_RUNNABLE)); }