public final class ImmediateThinScheduler extends Scheduler
Note that this doesn't support recursive scheduling and disposing the returned Disposable has no effect (because when the schedule() method returns, the task has been already run).
Scheduler.Worker
Modifier and Type | Field and Description |
---|---|
static Scheduler |
INSTANCE
The singleton instance of the immediate (thin) scheduler.
|
Modifier and Type | Method and Description |
---|---|
Scheduler.Worker |
createWorker()
Retrieves or creates a new
Scheduler.Worker that represents sequential execution of actions. |
Disposable |
scheduleDirect(Runnable run)
Schedules the given task on this Scheduler without any time delay.
|
Disposable |
scheduleDirect(Runnable run,
long delay,
TimeUnit unit)
Schedules the execution of the given task with the given time delay.
|
Disposable |
schedulePeriodicallyDirect(Runnable run,
long initialDelay,
long period,
TimeUnit unit)
Schedules a periodic execution of the given task with the given initial time delay and repeat period.
|
public static final Scheduler INSTANCE
@NonNull public Disposable scheduleDirect(@NonNull Runnable run)
Scheduler
This method is safe to be called from multiple threads but there are no ordering or non-overlapping guarantees between tasks.
scheduleDirect
in class Scheduler
run
- the task to execute@NonNull public Disposable scheduleDirect(@NonNull Runnable run, long delay, TimeUnit unit)
Scheduler
This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.
scheduleDirect
in class Scheduler
run
- the task to scheduledelay
- the delay amount, non-positive values indicate non-delayed schedulingunit
- the unit of measure of the delay amount@NonNull public Disposable schedulePeriodicallyDirect(@NonNull Runnable run, long initialDelay, long period, TimeUnit unit)
Scheduler
This method is safe to be called from multiple threads but there are no ordering guarantees between tasks.
The periodic execution is at a fixed rate, that is, the first execution will be after the
initialDelay
, the second after initialDelay + period
, the third after
initialDelay + 2 * period
, and so on.
schedulePeriodicallyDirect
in class Scheduler
run
- the task to scheduleinitialDelay
- the initial delay amount, non-positive values indicate non-delayed schedulingperiod
- the period at which the task should be re-executedunit
- the unit of measure of the delay amount@NonNull public Scheduler.Worker createWorker()
Scheduler
Scheduler.Worker
that represents sequential execution of actions.
When work is completed, the Worker
instance should be released
by calling Disposable.dispose()
to avoid potential resource leaks in the
underlying task-execution scheme.
Work on a Scheduler.Worker
is guaranteed to be sequential and non-overlapping.
createWorker
in class Scheduler
Copyright © 2018 JBoss by Red Hat. All rights reserved.