Class Scheduler<T>
java.lang.Object
dev.bouncingelf10.timelesslib.api.scheduler.Scheduler<T>
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSchedules a task to run after the specified delay.Schedules a task to run after the specified delay.afterAsync(Duration delay, Consumer<T> task) Schedules a task to run after the specified delay, returning aCompletableFuturethat completes when the task has finished executing.Schedules a repeating task to run at the specified interval.everyFixedRate(Duration period, Consumer<T> task) Schedules a repeating task to run at the specified interval, with a fixed delay between runs.
E.g.booleanbooleanvoidshutdown()If you're getting the scheduler throughTimelessLib.getServerScheduler()or the client counterpart you should NOT call this method.voidshutdownGracefully(long timeout, TimeUnit unit) If you're getting the scheduler throughTimelessLib.getServerScheduler()or the client counterpart you should NOT call this method.
-
Constructor Details
-
Scheduler
-
Scheduler
-
-
Method Details
-
after
Schedules a task to run after the specified delay.- Parameters:
delay- Delay before running the tasktask- Task to run- Returns:
TaskHandle
-
after
Schedules a task to run after the specified delay.- Parameters:
id- Unique ID for the taskdelay- Delay before running the tasktask- Task to run- Returns:
TaskHandle- Throws:
IllegalArgumentException- if a task with the specified ID already exists
-
every
Schedules a repeating task to run at the specified interval.- Parameters:
period- Interval between runstask- Task to run- Returns:
TaskHandle
-
everyFixedRate
Schedules a repeating task to run at the specified interval, with a fixed delay between runs.
E.g.every(Duration, Consumer)will run the interval after the task has finished executing, whereas this method will run the interval immediately after the task starts executing.- Parameters:
period-task-- Returns:
TaskHandle
-
afterAsync
Schedules a task to run after the specified delay, returning aCompletableFuturethat completes when the task has finished executing.- Parameters:
delay- Delay before running the tasktask- Task to run- Returns:
CompletableFuture
-
shutdown
public void shutdown()If you're getting the scheduler throughTimelessLib.getServerScheduler()or the client counterpart you should NOT call this method. -
shutdownGracefully
If you're getting the scheduler throughTimelessLib.getServerScheduler()or the client counterpart you should NOT call this method.- Throws:
InterruptedException
-
isShutdown
public boolean isShutdown() -
isTerminated
public boolean isTerminated()
-