/** * Delays the actual subscription to this Nono until the given * time passes. * @param delay the delay amount * @param unit the time unit * @param scheduler the scheduler to wait on * @return the new Nono instance */ public final Nono delaySubscription(long delay, TimeUnit unit, Scheduler scheduler) { return delaySubscription(timer(delay, unit, scheduler)); }
/** * Signals a TimeoutException if this Nono doesn't complete * within the specified timeout. * @param timeout the timeout amount * @param unit the time unit * @param scheduler the scheduler to wait on * @return the new Nono instance */ public final Nono timeout(long timeout, TimeUnit unit, Scheduler scheduler) { return timeout(timer(timeout, unit, scheduler)); }
/** * Signals a TimeoutException if this Nono doesn't complete * within the specified timeout. * @param timeout the timeout amount * @param unit the time unit * @param scheduler the scheduler to wait on * @return the new Nono instance */ public final Nono timeout(long timeout, TimeUnit unit, Scheduler scheduler) { return timeout(timer(timeout, unit, scheduler)); }
/** * Delays the actual subscription to this Nono until the given * time passes. * @param delay the delay amount * @param unit the time unit * @return the new Nono instance */ public final Nono delaySubscription(long delay, TimeUnit unit) { return delaySubscription(timer(delay, unit)); }
/** * Delays the actual subscription to this Nono until the given * time passes. * @param delay the delay amount * @param unit the time unit * @param scheduler the scheduler to wait on * @return the new Nono instance */ public final Nono delaySubscription(long delay, TimeUnit unit, Scheduler scheduler) { return delaySubscription(timer(delay, unit, scheduler)); }
/** * Delays the actual subscription to this Nono until the given * time passes. * @param delay the delay amount * @param unit the time unit * @return the new Nono instance */ public final Nono delaySubscription(long delay, TimeUnit unit) { return delaySubscription(timer(delay, unit)); }
/** * Completes after the specified amount of time on the computation scheduler. * @param delay the delay value * @param unit the delay time unit * @return the new Nono instance */ @SchedulerSupport(SchedulerSupport.COMPUTATION) public static Nono timer(long delay, TimeUnit unit) { return timer(delay, unit, Schedulers.computation()); }
/** * Completes after the specified amount of time on the computation scheduler. * @param delay the delay value * @param unit the delay time unit * @return the new Nono instance */ @SchedulerSupport(SchedulerSupport.COMPUTATION) public static Nono timer(long delay, TimeUnit unit) { return timer(delay, unit, Schedulers.computation()); }
/** * Switches to the fallback Nono if this Nono doesn't complete * within the specified timeout. * @param timeout the timeout amount * @param unit the time unit * @param scheduler the scheduler to wait on * @param fallback the Nono to switch to if this Nono times out * @return the new Nono instance */ public final Nono timeout(long timeout, TimeUnit unit, Scheduler scheduler, Nono fallback) { ObjectHelper.requireNonNull(unit, "unit is null"); ObjectHelper.requireNonNull(scheduler, "scheduler is null"); ObjectHelper.requireNonNull(fallback, "fallback is null"); return timeout(timer(timeout, unit, scheduler), fallback); }
/** * Switches to the fallback Nono if this Nono doesn't complete * within the specified timeout. * @param timeout the timeout amount * @param unit the time unit * @param scheduler the scheduler to wait on * @param fallback the Nono to switch to if this Nono times out * @return the new Nono instance */ public final Nono timeout(long timeout, TimeUnit unit, Scheduler scheduler, Nono fallback) { ObjectHelper.requireNonNull(unit, "unit is null"); ObjectHelper.requireNonNull(scheduler, "scheduler is null"); ObjectHelper.requireNonNull(fallback, "fallback is null"); return timeout(timer(timeout, unit, scheduler), fallback); }
@Test public void timer() { Nono.timer(100, TimeUnit.MILLISECONDS) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(); }
@Test public void timerScheduler() { Nono.timer(100, TimeUnit.MILLISECONDS, Schedulers.single()) .test() .awaitDone(5, TimeUnit.SECONDS) .assertResult(); }