public final class Schedulers
extends java.lang.Object
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 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.ImmediateScheduler
instancepublic static Scheduler trampoline()
Scheduler
that queues work on the current thread to be executed after the
current work completes.TrampolineScheduler
instancepublic static Scheduler newThread()
Scheduler
that creates a new Thread
for each unit of work.NewThreadScheduler
instancepublic 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 Schedulers.io()
instead.
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 Schedulers.computation()
instead.
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 wrap