- All Superinterfaces:
Executor
- All Known Implementing Classes:
SchedulerManager
Represents a scheduler that will execute tasks with a precision based on its ticking rate.
If precision is important, consider using a JDK executor service or any third party library.
Tasks are by default executed in the caller thread.
-
Method Summary
Modifier and TypeMethodDescriptiondefault Task.Builder
default void
Implementation ofExecutor
, proxies toscheduleNextTick(Runnable)
.static Scheduler
void
process()
Process scheduled tasks based on time to increase scheduling precision.void
Advance 1 tick and callprocess()
.void
Execute tasks set to run at the end of this tick.default Task
scheduleEndOfTick
(Runnable task) default Task
scheduleNextProcess
(Runnable task) default Task
scheduleNextProcess
(Runnable task, ExecutionType executionType) default Task
scheduleNextTick
(Runnable task) default Task
scheduleNextTick
(Runnable task, ExecutionType executionType) default Task
scheduleTask
(Runnable task, TaskSchedule delay, TaskSchedule repeat) default Task
scheduleTask
(Runnable task, TaskSchedule delay, TaskSchedule repeat, ExecutionType executionType) default Task
scheduleTask
(Supplier<TaskSchedule> task, TaskSchedule delay) default Task
submitTask
(Supplier<TaskSchedule> task) submitTask
(Supplier<TaskSchedule> task, ExecutionType executionType) Submits a new task with custom scheduling logic.
-
Method Details
-
newScheduler
-
process
void process()Process scheduled tasks based on time to increase scheduling precision.This method is not thread-safe.
-
processTick
void processTick()Advance 1 tick and callprocess()
.This method is not thread-safe.
-
processTickEnd
void processTickEnd()Execute tasks set to run at the end of this tick.This method is not thread-safe.
-
submitTask
Submits a new task with custom scheduling logic.This is the primitive method used by all scheduling shortcuts,
task
is immediately executed in the caller thread to retrieve its scheduling state and the task will stay alive as long asTaskSchedule.stop()
is not returned (orTask.cancel()
is called).- Parameters:
task
- the task to be directly executed in the caller threadexecutionType
- the execution type- Returns:
- the created task
-
submitTask
-
buildTask
-
scheduleTask
default Task scheduleTask(Runnable task, TaskSchedule delay, TaskSchedule repeat, ExecutionType executionType) -
scheduleTask
-
scheduleTask
-
scheduleNextTick
-
scheduleNextTick
-
scheduleEndOfTick
-
scheduleNextProcess
-
scheduleNextProcess
-
execute
Implementation ofExecutor
, proxies toscheduleNextTick(Runnable)
.
-