public class Scheduler
extends java.lang.Object
implements java.lang.Runnable, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
Scheduler.State
State of the scheduler
|
Constructor and Description |
---|
Scheduler(Schedulable... _schedulables)
Constructor which set the initial state and auto start if requested
|
Modifier and Type | Method and Description |
---|---|
void |
add(Schedulable _schedulable)
Plan to add a schedulable
|
void |
addOnChange(java.util.function.Consumer<Scheduler> _onChange)
Add a method that must be executed when the scheduler speed is changed
|
static Scheduler |
getDefaultScheduler()
Create or return the default scheduler
|
int |
getSleep()
Getter for the sleep time
|
boolean |
isRunning()
Is the scheduler running ?
|
void |
lock()
Soft lock the scheduler to avoid a too early running
|
void |
remove(Schedulable _schedulable)
Plan to remove a schedulable
|
void |
run()
Threaded run method
|
void |
setOnStop(java.util.function.Consumer<Scheduler> _onStop)
Set the method that must be executed when the system is stopped
|
void |
setSleep(int sleep)
Setter for the sleep time
|
void |
start()
Start (or continue) with no delay between cycles
|
void |
startWithSleep(int i)
Set the delay between two cycles and launch the scheduler if it is not
running
|
void |
step()
Execute one cycle
|
void |
stop()
Stop the scheduler if it is running
|
void |
unlock()
Soft unlock the scheduler to avoid a too early running
|
public Scheduler(Schedulable... _schedulables)
_schedulables
- the corresponding schedulablespublic static Scheduler getDefaultScheduler()
public void startWithSleep(int i)
i
- the delay between two cyclespublic void start()
public void step()
public void stop()
public void run()
run
in interface java.lang.Runnable
public final void setOnStop(java.util.function.Consumer<Scheduler> _onStop)
_onStop
- Consumer methodpublic final void addOnChange(java.util.function.Consumer<Scheduler> _onChange)
_onChange
- Consumer methodpublic boolean isRunning()
public int getSleep()
public void setSleep(int sleep)
sleep
- The time between each cyclepublic void add(Schedulable _schedulable)
_schedulable
- the schedulable to addpublic void remove(Schedulable _schedulable)
_schedulable
- the schedulable to removepublic void lock()
public void unlock()