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_PRIORITY
rx2.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_PRIORITY
rx2.newthread-priority
(int): sets the thread priority of the newThread()
Scheduler, default is Thread.NORM_PRIORITY
rx2.single-priority
(int): sets the thread priority of the single()
Scheduler, default is Thread.NORM_PRIORITY
rx2.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 secondModifier 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. |
@NonNull 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 work@NonNull public 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 work@NonNull public 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 thread@NonNull public 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 threads@NonNull public static Scheduler single()
Uses:
Scheduler
that shares a single backing thread.@NonNull public static Scheduler from(@NonNull 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.