public interface Scheduler
Modifier and Type | Interface and Description |
---|---|
static interface |
Scheduler.Worker
A worker representing an asynchronous boundary that executes tasks in
a FIFO order, guaranteed non-concurrently with respect to each other.
|
Modifier and Type | Field and Description |
---|---|
static Cancellation |
REJECTED
Returned by the schedule() methods if the Scheduler or the Worker has ben shut down.
|
Modifier and Type | Method and Description |
---|---|
Scheduler.Worker |
createWorker()
Creates a worker of this Scheduler that executed task in a strict
FIFO order, guaranteed non-concurrently with each other.
|
Cancellation |
schedule(java.lang.Runnable task)
Schedules the given task on this scheduler non-delayed execution.
|
default void |
shutdown()
Instructs this Scheduler to release all resources and reject
any new tasks to be executed.
|
default void |
start()
Instructs this Scheduler to prepare itself for running tasks
directly or through its Workers.
|
static final Cancellation REJECTED
Cancellation schedule(java.lang.Runnable task)
This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.
task
- the task to executeCancellation
instance that let's one cancel this particular task.
If the Scheduler
has been shut down, the REJECTED
Cancellation
instance is returned.Scheduler.Worker createWorker()
Once the Worker is no longer in use, one should call shutdown() on it to release any resources the particular Scheduler may have used.
Tasks scheduled with this worker run in FIFO order and strictly non-concurrently, but there are no ordering guarantees between different Workers created from the same Scheduler.
default void start()
The operation is thread-safe but one should avoid using start() and shutdown() concurrently as it would non-deterministically leave the Scheduler in either active or inactive state.
default void shutdown()
The operation is thread-safe but one should avoid using start() and shutdown() concurrently as it would non-deterministically leave the Scheduler in either active or inactive state.