RxJava



rx.concurrency
Class Schedulers

java.lang.Object
  extended by rx.concurrency.Schedulers

public class Schedulers
extends java.lang.Object

Static factory methods for creating Schedulers.


Method Summary
static Scheduler currentThread()
          Scheduler that queues work on the current thread to be executed after the current work completes.
static Scheduler executor(java.util.concurrent.Executor executor)
          Scheduler that queues work on an Executor.
static Scheduler executor(java.util.concurrent.ScheduledExecutorService executor)
          Scheduler that queues work on an ScheduledExecutorService.
static Scheduler immediate()
          Scheduler that executes work immediately on the current thread.
static Scheduler newThread()
          Scheduler that creates a new Thread for each unit of work.
static Scheduler threadPoolForComputation()
          Scheduler intended for computational work.
static Scheduler threadPoolForIO()
          Scheduler intended for IO-bound work.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

immediate

public static Scheduler immediate()
Scheduler that executes work immediately on the current thread.

Returns:
ImmediateScheduler instance

currentThread

public static Scheduler currentThread()
Scheduler that queues work on the current thread to be executed after the current work completes.

Returns:
CurrentThreadScheduler instance

newThread

public static Scheduler newThread()
Scheduler that creates a new Thread for each unit of work.

Returns:
NewThreadScheduler instance

executor

public static Scheduler executor(java.util.concurrent.Executor executor)
Scheduler that queues work on an Executor.

Note that this does not support scheduled actions with a delay.

Returns:
ExecutorScheduler instance

executor

public static Scheduler executor(java.util.concurrent.ScheduledExecutorService executor)
Scheduler that queues work on an ScheduledExecutorService.

Returns:
ExecutorScheduler instance

threadPoolForComputation

public static Scheduler threadPoolForComputation()
Scheduler intended for computational work.

The implementation is backed by a ScheduledExecutorService thread-pool sized to the number of CPU cores.

This can be used for event-loops, processing callbacks and other computational work.

Do not perform IO-bound work on this scheduler. Use Schedulers.threadPoolForComputation() instead.

Returns:
ExecutorScheduler for computation-bound work.

threadPoolForIO

public static Scheduler threadPoolForIO()
Scheduler intended for IO-bound work.

The implementation is backed by an Executor thread-pool that will grow as needed.

This can be used for asynchronously performing blocking IO.

Do not perform computational work on this scheduler. Use Schedulers.threadPoolForComputation() instead.

Returns:
ExecutorScheduler for IO-bound work.