Top Description Fields Constructors Methods
rx.schedulers

public final Class Schedulers

extends Object
Class Inheritance
Imports
java.util.concurrent.Executor, java.util.concurrent.atomic.AtomicReference, rx.Scheduler, rx.internal.schedulers.*, rx.plugins.*

Static factory methods for creating Schedulers.

System configuration properties:

Property nameDescriptionDefault
rx.io-scheduler.keepalivetime (in seconds) to keep an unused backing thread-pool60
rx.scheduler.max-computation-threadsnumber of threads the computation scheduler uses (between 1 and number of available processors) number of available processors.
rx.scheduler.jdk6.purge-frequency-millistime (in milliseconds) between calling purge on any active backing thread-pool on a Java 6 runtime1000
rx.scheduler.jdk6.purge-force boolean forcing the call to purge on any active backing thread-poolfalse

Field Summary

Modifier and TypeField and Description
private final Scheduler
private static final AtomicReference<Schedulers>
private final Scheduler
private final Scheduler

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static Scheduler

Returns:

a Scheduler meant for computation-bound work
computation
()

Creates and returns a Scheduler intended for computational work.

public static Scheduler

Returns:

the new Scheduler wrapping the Executor
from
(Executor
the executor to wrap
executor
)

Converts an Executor into a new Scheduler instance.

private static Schedulers
public static Scheduler

Returns:

a Scheduler that executes work immediately
immediate
()

Creates and returns a Scheduler that executes work immediately on the current thread.

public static Scheduler

Returns:

a Scheduler meant for IO-bound work
io
()

Creates and returns a Scheduler intended for IO-bound work.

public static Scheduler

Returns:

a Scheduler that creates new threads
newThread
()

Creates and returns a Scheduler that creates a new Thread for each unit of work.

public static void
reset()

Resets the current Schedulers instance.

public static void
shutdown()

Shuts down those standard Schedulers which support the SchedulerLifecycle interface.

pack-priv synchronized void
shutdownInstance()

Start the instance-specific schedulers.

public static void
start()

Starts those standard Schedulers which support the SchedulerLifecycle interface.

pack-priv synchronized void
startInstance()

Start the instance-specific schedulers.

public static TestScheduler

Returns:

a TestScheduler meant for debugging
test
()

Creates and returns a TestScheduler, which is useful for debugging.

public static Scheduler

Returns:

a Scheduler that queues work on the current thread
trampoline
()

Creates and returns a Scheduler that queues work on the current thread to be executed after the current work completes.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

computationSchedulerback to summary
private final Scheduler computationScheduler
INSTANCEback to summary
private static final AtomicReference<Schedulers> INSTANCE
ioSchedulerback to summary
private final Scheduler ioScheduler
newThreadSchedulerback to summary
private final Scheduler newThreadScheduler

Constructor Detail

Schedulersback to summary
private Schedulers()

Method Detail

computationback to summary
public static Scheduler computation()

Creates and returns a Scheduler intended for computational work.

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

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

Unhandled errors will be delivered to the scheduler Thread's java.lang.Thread.UncaughtExceptionHandler.

Returns:Scheduler

a Scheduler meant for computation-bound work

fromback to summary
public static Scheduler from(Executor executor)

Converts an Executor into a new Scheduler instance.

Parameters
executor:Executor

the executor to wrap

Returns:Scheduler

the new Scheduler wrapping the Executor

getInstanceback to summary
private static Schedulers getInstance()
immediateback to summary
public static Scheduler immediate()

Creates and returns a Scheduler that executes work immediately on the current thread.

Returns:Scheduler

a Scheduler that executes work immediately

ioback to summary
public static Scheduler io()

Creates and returns a 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 computation() instead.

Unhandled errors will be delivered to the scheduler Thread's java.lang.Thread.UncaughtExceptionHandler.

Returns:Scheduler

a Scheduler meant for IO-bound work

newThreadback to summary
public static Scheduler newThread()

Creates and returns a Scheduler that creates a new Thread for each unit of work.

Unhandled errors will be delivered to the scheduler Thread's java.lang.Thread.UncaughtExceptionHandler.

Returns:Scheduler

a Scheduler that creates new threads

resetback to summary
public static void reset()

Resets the current Schedulers instance. This will re-init the cached schedulers on the next usage, which can be useful in testing.

Since
1.3
shutdownback to summary
public static void shutdown()

Shuts down those standard Schedulers which support the SchedulerLifecycle interface.

The operation is idempotent and thread-safe.

shutdownInstanceback to summary
pack-priv synchronized void shutdownInstance()

Start the instance-specific schedulers.

startback to summary
public static void start()

Starts those standard Schedulers which support the SchedulerLifecycle interface.

The operation is idempotent and thread-safe.

startInstanceback to summary
pack-priv synchronized void startInstance()

Start the instance-specific schedulers.

testback to summary
public static TestScheduler test()

Creates and returns a TestScheduler, which is useful for debugging. It allows you to test schedules of events by manually advancing the clock at whatever pace you choose.

Returns:TestScheduler

a TestScheduler meant for debugging

trampolineback to summary
public static Scheduler trampoline()

Creates and returns a Scheduler that queues work on the current thread to be executed after the current work completes.

Returns:Scheduler

a Scheduler that queues work on the current thread