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.Builderdefault voidImplementation ofExecutor, proxies toscheduleNextTick(Runnable).static @NotNull Schedulervoidprocess()Process scheduled tasks based on time to increase scheduling precision.voidAdvance 1 tick and callprocess().voidExecute tasks set to run at the end of this tick.default @NotNull TaskscheduleEndOfTick(@NotNull Runnable task) default @NotNull TaskscheduleNextProcess(@NotNull Runnable task) default @NotNull TaskscheduleNextProcess(@NotNull Runnable task, @NotNull ExecutionType executionType) default @NotNull TaskscheduleNextTick(@NotNull Runnable task) default @NotNull TaskscheduleNextTick(@NotNull Runnable task, @NotNull ExecutionType executionType) default @NotNull TaskscheduleTask(@NotNull Runnable task, @NotNull TaskSchedule delay, @NotNull TaskSchedule repeat) default @NotNull TaskscheduleTask(@NotNull Runnable task, @NotNull TaskSchedule delay, @NotNull TaskSchedule repeat, @NotNull ExecutionType executionType) default @NotNull TaskscheduleTask(@NotNull Supplier<TaskSchedule> task, @NotNull TaskSchedule delay) default @NotNull TasksubmitTask(@NotNull Supplier<TaskSchedule> task) @NotNull TasksubmitTask(@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,
taskis 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).
-