Package dev.demeng.pluginbase.scheduler
Interface Scheduler
- All Superinterfaces:
Executor
Utility for scheduling tasks
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> @NotNull Promise<T>Compute the result of the passed callable.default <T> @NotNull Promise<T>Compute the result of the passed callable at some point in the futuredefault <T> @NotNull Promise<T>Compute the result of the passed callable at some point in the future@NotNull ThreadContextGets the context this scheduler operates in.Execute the passed runnableExecute the passed runnable at some point in the futureExecute the passed runnable at some point in the futuredefault @NotNull TaskrunRepeating(@NotNull Runnable runnable, long delayTicks, long intervalTicks) Schedule a repeating task to rundefault @NotNull TaskrunRepeating(@NotNull Runnable runnable, long delay, @NotNull TimeUnit delayUnit, long interval, @NotNull TimeUnit intervalUnit) Schedule a repeating task to run@NotNull TaskrunRepeating(@NotNull Consumer<Task> consumer, long delayTicks, long intervalTicks) Schedule a repeating task to run@NotNull TaskrunRepeating(@NotNull Consumer<Task> consumer, long delay, @NotNull TimeUnit delayUnit, long interval, @NotNull TimeUnit intervalUnit) Schedule a repeating task to rundefault <T> @NotNull Promise<T>Compute the result of the passed supplier.default <T> @NotNull Promise<T>supplyLater(@NotNull Supplier<T> supplier, long delayTicks) Compute the result of the passed supplier at some point in the futuredefault <T> @NotNull Promise<T>supplyLater(@NotNull Supplier<T> supplier, long delay, @NotNull TimeUnit unit) Compute the result of the passed supplier at some point in the future
-
Method Details
-
getContext
Gets the context this scheduler operates in.- Returns:
- the context
-
supply
Compute the result of the passed supplier.- Type Parameters:
T- the return type- Parameters:
supplier- the supplier- Returns:
- a Promise which will return the result of the computation
-
call
Compute the result of the passed callable.- Type Parameters:
T- the return type- Parameters:
callable- the callable- Returns:
- a Promise which will return the result of the computation
-
run
Execute the passed runnable- Parameters:
runnable- the runnable- Returns:
- a Promise which will return when the runnable is complete
-
supplyLater
@NotNull default <T> @NotNull Promise<T> supplyLater(@NotNull @NotNull Supplier<T> supplier, long delayTicks) Compute the result of the passed supplier at some point in the future- Type Parameters:
T- the return type- Parameters:
supplier- the supplierdelayTicks- the delay in ticks before calling the supplier- Returns:
- a Promise which will return the result of the computation
-
supplyLater
@NotNull default <T> @NotNull Promise<T> supplyLater(@NotNull @NotNull Supplier<T> supplier, long delay, @NotNull @NotNull TimeUnit unit) Compute the result of the passed supplier at some point in the future- Type Parameters:
T- the return type- Parameters:
supplier- the supplierdelay- the delay to wait before calling the supplierunit- the unit of delay- Returns:
- a Promise which will return the result of the computation
-
callLater
@NotNull default <T> @NotNull Promise<T> callLater(@NotNull @NotNull Callable<T> callable, long delayTicks) Compute the result of the passed callable at some point in the future- Type Parameters:
T- the return type- Parameters:
callable- the callabledelayTicks- the delay in ticks before calling the supplier- Returns:
- a Promise which will return the result of the computation
-
callLater
@NotNull default <T> @NotNull Promise<T> callLater(@NotNull @NotNull Callable<T> callable, long delay, @NotNull @NotNull TimeUnit unit) Compute the result of the passed callable at some point in the future- Type Parameters:
T- the return type- Parameters:
callable- the callabledelay- the delay to wait before calling the supplierunit- the unit of delay- Returns:
- a Promise which will return the result of the computation
-
runLater
@NotNull default @NotNull Promise<Void> runLater(@NotNull @NotNull Runnable runnable, long delayTicks) Execute the passed runnable at some point in the future- Parameters:
runnable- the runnabledelayTicks- the delay in ticks before calling the supplier- Returns:
- a Promise which will return when the runnable is complete
-
runLater
@NotNull default @NotNull Promise<Void> runLater(@NotNull @NotNull Runnable runnable, long delay, @NotNull @NotNull TimeUnit unit) Execute the passed runnable at some point in the future- Parameters:
runnable- the runnabledelay- the delay to wait before calling the supplierunit- the unit of delay- Returns:
- a Promise which will return when the runnable is complete
-
runRepeating
@NotNull @NotNull Task runRepeating(@NotNull @NotNull Consumer<Task> consumer, long delayTicks, long intervalTicks) Schedule a repeating task to run- Parameters:
consumer- the task to rundelayTicks- the delay before the task beginsintervalTicks- the interval at which the task will repeat- Returns:
- a task instance
-
runRepeating
@NotNull @NotNull Task runRepeating(@NotNull @NotNull Consumer<Task> consumer, long delay, @NotNull @NotNull TimeUnit delayUnit, long interval, @NotNull @NotNull TimeUnit intervalUnit) Schedule a repeating task to run- Parameters:
consumer- the task to rundelay- the delay before the task beginsdelayUnit- the unit of delayinterval- the interval at which the task will repeatintervalUnit- the- Returns:
- a task instance
-
runRepeating
@NotNull default @NotNull Task runRepeating(@NotNull @NotNull Runnable runnable, long delayTicks, long intervalTicks) Schedule a repeating task to run- Parameters:
runnable- the task to rundelayTicks- the delay before the task beginsintervalTicks- the interval at which the task will repeat- Returns:
- a task instance
-
runRepeating
@NotNull default @NotNull Task runRepeating(@NotNull @NotNull Runnable runnable, long delay, @NotNull @NotNull TimeUnit delayUnit, long interval, @NotNull @NotNull TimeUnit intervalUnit) Schedule a repeating task to run- Parameters:
runnable- the task to rundelay- the delay before the task beginsdelayUnit- the unit of delayinterval- the interval at which the task will repeatintervalUnit- the- Returns:
- a task instance
-