public final class Schedulers
extends java.lang.Object
System configuration properties:
Property name | Description | Default |
rx.io-scheduler.keepalive | time (in seconds) to keep an unused backing thread-pool | 60 |
rx.scheduler.max-computation-threads | number of threads the computation scheduler uses (between 1 and number of available processors) | number of available processors. |
rx.scheduler.jdk6.purge-frequency-millis | time (in milliseconds) between calling purge on any active backing thread-pool on a Java 6 runtime | 1000 |
rx.scheduler.jdk6.purge-force | boolean forcing the call to purge on any active backing thread-pool | false |
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 |
immediate()
Creates and returns a
Scheduler that executes work immediately on the current thread. |
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 |
reset()
Resets the current
Schedulers instance. |
static void |
shutdown()
Shuts down those standard Schedulers which support the SchedulerLifecycle interface.
|
static void |
start()
Starts those standard Schedulers which support the SchedulerLifecycle interface.
|
static TestScheduler |
test()
Creates and returns a
TestScheduler , which is useful for debugging. |
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 immediate()
Scheduler
that executes work immediately on the current thread.Scheduler
that executes work immediatelypublic 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 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 TestScheduler test()
TestScheduler
, which is useful for debugging. It allows you to test
schedules of events by manually advancing the clock at whatever pace you choose.TestScheduler
meant for debuggingpublic static Scheduler from(java.util.concurrent.Executor executor)
Executor
into a new Scheduler instance.executor
- the executor to wrappublic static void reset()
Schedulers
instance.
This will re-init the cached schedulers on the next usage,
which can be useful in testing.public static void start()
The operation is idempotent and thread-safe.
public static void shutdown()
The operation is idempotent and thread-safe.