Package net.minestom.server.timer
Interface Scheduler
- 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 @NotNull 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 @NotNull Task
scheduleEndOfTick
(@NotNull Runnable task) default @NotNull Task
scheduleNextProcess
(@NotNull Runnable task) default @NotNull Task
scheduleNextProcess
(@NotNull Runnable task, @NotNull ExecutionType executionType) default @NotNull Task
scheduleNextTick
(@NotNull Runnable task) default @NotNull Task
scheduleNextTick
(@NotNull Runnable task, @NotNull ExecutionType executionType) default @NotNull Task
scheduleTask
(@NotNull Runnable task, @NotNull TaskSchedule delay, @NotNull TaskSchedule repeat) default @NotNull Task
scheduleTask
(@NotNull Runnable task, @NotNull TaskSchedule delay, @NotNull TaskSchedule repeat, @NotNull ExecutionType executionType) default @NotNull Task
scheduleTask
(@NotNull Supplier<TaskSchedule> task, @NotNull TaskSchedule delay) default @NotNull Task
submitTask
(@NotNull Supplier<TaskSchedule> task) @NotNull Task
submitTask
(@NotNull Supplier<TaskSchedule> task, @NotNull 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
@NotNull @NotNull Task submitTask(@NotNull @NotNull Supplier<TaskSchedule> task, @NotNull @NotNull ExecutionType executionType) 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
@NotNull default @NotNull Task scheduleTask(@NotNull @NotNull Runnable task, @NotNull @NotNull TaskSchedule delay, @NotNull @NotNull TaskSchedule repeat, @NotNull @NotNull ExecutionType executionType) -
scheduleTask
@NotNull default @NotNull Task scheduleTask(@NotNull @NotNull Runnable task, @NotNull @NotNull TaskSchedule delay, @NotNull @NotNull TaskSchedule repeat) -
scheduleTask
@NotNull default @NotNull Task scheduleTask(@NotNull @NotNull Supplier<TaskSchedule> task, @NotNull @NotNull TaskSchedule delay) -
scheduleNextTick
@NotNull default @NotNull Task scheduleNextTick(@NotNull @NotNull Runnable task, @NotNull @NotNull ExecutionType executionType) -
scheduleNextTick
-
scheduleEndOfTick
-
scheduleNextProcess
@NotNull default @NotNull Task scheduleNextProcess(@NotNull @NotNull Runnable task, @NotNull @NotNull ExecutionType executionType) -
scheduleNextProcess
-
execute
Implementation ofExecutor
, proxies toscheduleNextTick(Runnable)
.
-