RxJava



rx.concurrency
Class ExecutorScheduler

java.lang.Object
  extended by rx.Scheduler
      extended by rx.concurrency.ExecutorScheduler

public class ExecutorScheduler
extends Scheduler

A Scheduler implementation that uses an Executor or ScheduledExecutorService implementation.

Note that if an Executor implementation is used instead of ScheduledExecutorService then a system-wide Timer will be used to handle delayed events.


Constructor Summary
ExecutorScheduler(java.util.concurrent.Executor executor)
           
ExecutorScheduler(java.util.concurrent.ScheduledExecutorService executor)
           
 
Method Summary
<T> Subscription
schedule(T state, Func2<? super Scheduler,? super T,? extends Subscription> action)
          Schedules a cancelable action to be executed.
<T> Subscription
schedule(T state, Func2<? super Scheduler,? super T,? extends Subscription> action, long delayTime, java.util.concurrent.TimeUnit unit)
          Schedules a cancelable action to be executed in delayTime.
<T> Subscription
schedulePeriodically(T state, Func2<? super Scheduler,? super T,? extends Subscription> action, long initialDelay, long period, java.util.concurrent.TimeUnit unit)
          Schedules a cancelable action to be executed periodically.
 
Methods inherited from class rx.Scheduler
degreeOfParallelism, now, schedule, schedule, schedule, schedule, schedulePeriodically
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ExecutorScheduler

public ExecutorScheduler(java.util.concurrent.Executor executor)

ExecutorScheduler

public ExecutorScheduler(java.util.concurrent.ScheduledExecutorService executor)
Method Detail

schedulePeriodically

public <T> Subscription schedulePeriodically(T state,
                                             Func2<? super Scheduler,? super T,? extends Subscription> action,
                                             long initialDelay,
                                             long period,
                                             java.util.concurrent.TimeUnit unit)
Description copied from class: Scheduler
Schedules a cancelable action to be executed periodically. This default implementation schedules recursively and waits for actions to complete (instead of potentially executing long-running actions concurrently). Each scheduler that can do periodic scheduling in a better way should override this.

Overrides:
schedulePeriodically in class Scheduler
Parameters:
state - State to pass into the action.
action - The action to execute periodically.
initialDelay - Time to wait before executing the action for the first time.
period - The time interval to wait each time in between executing the action.
unit - The time unit the interval above is given in.
Returns:
A subscription to be able to unsubscribe from action.

schedule

public <T> Subscription schedule(T state,
                                 Func2<? super Scheduler,? super T,? extends Subscription> action,
                                 long delayTime,
                                 java.util.concurrent.TimeUnit unit)
Description copied from class: Scheduler
Schedules a cancelable action to be executed in delayTime.

Specified by:
schedule in class Scheduler
Parameters:
state - State to pass into the action.
action - Action to schedule.
delayTime - Time the action is to be delayed before executing.
unit - Time unit of the delay time.
Returns:
a subscription to be able to unsubscribe from action.

schedule

public <T> Subscription schedule(T state,
                                 Func2<? super Scheduler,? super T,? extends Subscription> action)
Description copied from class: Scheduler
Schedules a cancelable action to be executed.

Specified by:
schedule in class Scheduler
Parameters:
state - State to pass into the action.
action - Action to schedule.
Returns:
a subscription to be able to unsubscribe from action.