Java Code Examples for io.reactivex.plugins.RxJavaPlugins#onSchedule()

The following examples show how to use io.reactivex.plugins.RxJavaPlugins#onSchedule() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HandlerScheduler.java    From atlas with Apache License 2.0 6 votes vote down vote up
@Override
public Disposable schedule(Runnable run, long delay, TimeUnit unit) {
    if (run == null) throw new NullPointerException("run == null");
    if (unit == null) throw new NullPointerException("unit == null");

    if (disposed) {
        return Disposables.disposed();
    }

    run = RxJavaPlugins.onSchedule(run);

    ScheduledRunnable scheduled = new ScheduledRunnable(handler, run);

    Message message = Message.obtain(handler, scheduled);
    message.obj = this; // Used as token for batch disposal of this worker's runnables.

    handler.sendMessageDelayed(message, Math.max(0L, unit.toMillis(delay)));

    // Re-check disposed state for removing in case we were racing a call to dispose().
    if (disposed) {
        handler.removeCallbacks(scheduled);
        return Disposables.disposed();
    }

    return scheduled;
}
 
Example 2
Source File: HandlerScheduler.java    From atlas with Apache License 2.0 5 votes vote down vote up
@Override
public Disposable scheduleDirect(Runnable run, long delay, TimeUnit unit) {
    if (run == null) throw new NullPointerException("run == null");
    if (unit == null) throw new NullPointerException("unit == null");

    run = RxJavaPlugins.onSchedule(run);
    ScheduledRunnable scheduled = new ScheduledRunnable(handler, run);
    handler.postDelayed(scheduled, Math.max(0L, unit.toMillis(delay)));
    return scheduled;
}
 
Example 3
Source File: ContextScheduler.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Override
public Disposable schedule(Runnable action, long delayTime, TimeUnit unit) {
  action = RxJavaPlugins.onSchedule(action);
  long delayMillis = unit.toMillis(delayTime);
  TimedAction timed = new TimedAction(action, 0);
  actions.put(timed, DUMB);
  timed.schedule(delayMillis);
  return timed;
}
 
Example 4
Source File: ContextScheduler.java    From vertx-rx with Apache License 2.0 5 votes vote down vote up
@Override
public Disposable schedulePeriodically(Runnable action, long initialDelay, long period, TimeUnit unit) {
  action = RxJavaPlugins.onSchedule(action);
  long delayMillis = unit.toMillis(initialDelay);
  TimedAction timed = new TimedAction(action, unit.toMillis(period));
  actions.put(timed, DUMB);
  timed.schedule(delayMillis);
  return timed;
}