public final class Schedulers
extends java.lang.Object
Supported system properties (System.getProperty()):
rx2.io-priority (int): sets the thread priority of the io() Scheduler, default is Thread.NORM_PRIORITYrx2.computation-threads (int): sets the number of threads in the computation() Scheduler, default is the number of available CPUsrx2.computation-priority (int): sets the thread priority of the computation() Scheduler, default is Thread.NORM_PRIORITYrx2.newthread-priority (int): sets the thread priority of the newThread() Scheduler, default is Thread.NORM_PRIORITYrx2.single-priority (int): sets the thread priority of the single() Scheduler, default is Thread.NORM_PRIORITYrx2.purge-enabled (boolean): enables periodic purging of all Scheduler's backing thread pools, default is falserx2.purge-period-seconds (int): specifies the periodic purge interval of all Scheduler's backing thread pools, default is 1 second| Modifier and Type | Method and Description |
|---|---|
static Scheduler |
computation()
Creates and returns a
Scheduler intended for computational work. |
static Scheduler |
from(java.util.concurrent.Executor executor)
Converts an
Executor into a new Scheduler instance. |
static Scheduler |
io()
Creates and returns a
Scheduler intended for IO-bound work. |
static Scheduler |
newThread()
Creates and returns a
Scheduler that creates a new Thread for each unit of work. |
static void |
shutdown()
Shuts down those standard Schedulers which support the SchedulerLifecycle interface.
|
static Scheduler |
single()
Returns the common, single-thread backed Scheduler instance.
|
static void |
start()
Starts those standard Schedulers which support the SchedulerLifecycle interface.
|
static Scheduler |
trampoline()
Creates and returns a
Scheduler that queues work on the current thread to be executed after the
current work completes. |
public static Scheduler computation()
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 Thread.UncaughtExceptionHandler.
Scheduler meant for computation-bound workpublic static Scheduler io()
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 Thread.UncaughtExceptionHandler.
Scheduler meant for IO-bound workpublic static Scheduler trampoline()
Scheduler that queues work on the current thread to be executed after the
current work completes.Scheduler that queues work on the current threadpublic static Scheduler newThread()
Scheduler that creates a new Thread for each unit of work.
Unhandled errors will be delivered to the scheduler Thread's Thread.UncaughtExceptionHandler.
Scheduler that creates new threadspublic static Scheduler single()
Uses:
Scheduler that shares a single backing thread.public static Scheduler from(java.util.concurrent.Executor executor)
Executor into a new Scheduler instance.executor - the executor to wrappublic static void shutdown()
The operation is idempotent and thread-safe.
public static void start()
The operation is idempotent and thread-safe.