@NonnullByDefault public final class Scheduler extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Scheduler.Task
Represents a scheduled repeating task
|
| Modifier and Type | Field and Description |
|---|---|
static Consumer<Throwable> |
EXCEPTION_CONSUMER |
| Modifier and Type | Method and Description |
|---|---|
static Executor |
async()
Returns an "async" executor, which executes all passed runnables asynchronously
|
static TaskBuilder |
builder()
Gets a
TaskBuilder instance |
static BukkitScheduler |
bukkit()
Gets Bukkit's scheduler.
|
static Executor |
bukkitAsync()
Returns a variant of
async(), which always uses the BukkitScheduler's
thread pool to execute tasks. |
static <T> Promise<T> |
call(ThreadContext context,
Callable<T> callable)
Call a callable
|
static <T> Promise<T> |
callAsync(Callable<T> callable)
Call a callable asynchronously
|
static <T> Promise<T> |
callLater(ThreadContext context,
Callable<T> callable,
long delay)
Call a callable at some point in the future
|
static <T> Promise<T> |
callLaterAsync(Callable<T> callable,
long delay)
Call a callable asynchronously at some point in the future
|
static <T> Promise<T> |
callLaterSync(Callable<T> callable,
long delay)
Call a callable on the main thread at some point in the future
|
static <T> Promise<T> |
callSync(Callable<T> callable)
Call a callable on the main server thread
|
static <T> Consumer<T> |
consuming(ThreadContext context,
Consumer<? super T> action)
Returns a consumer which when supplied, will delegate calls to the given
consumer (a)synchronously.
|
static <T> Consumer<T> |
consumingAsync(Consumer<? super T> action)
Returns a consumer which when supplied, will delegate calls to the given
consumer asynchronously.
|
static <T> Consumer<T> |
consumingSync(Consumer<? super T> action)
Returns a consumer which when supplied, will delegate calls to the given
consumer on the main server thread.
|
static ExecutorService |
internalAsync()
Returns a variant of
async() which uses an internal thread pool
to execute tasks. |
static Promise<Void> |
run(ThreadContext context,
Runnable runnable)
Execute a runnable
|
static Promise<Void> |
runAsync(Runnable runnable)
Execute a runnable asynchronously
|
static Promise<Void> |
runLater(ThreadContext context,
Runnable runnable,
long delay)
Execute a runnable at some point in the future
|
static Promise<Void> |
runLaterAsync(Runnable runnable,
long delay)
Execute a runnable asynchronously at some point in the future
|
static Promise<Void> |
runLaterSync(Runnable runnable,
long delay)
Execute a runnable on the main server thread at some point in the future
|
static Promise<Void> |
runSync(Runnable runnable)
Execute a runnable on the main server thread
|
static Scheduler.Task |
runTaskRepeating(ThreadContext context,
Consumer<Scheduler.Task> consumer,
long delay,
long interval)
Schedule a repeating task to run
|
static Scheduler.Task |
runTaskRepeating(ThreadContext context,
Runnable runnable,
long delay,
long interval)
Schedule a repeating task to run
|
static Scheduler.Task |
runTaskRepeatingAsync(Consumer<Scheduler.Task> consumer,
long delay,
long interval)
Schedule a repeating task to run asynchronously
|
static Scheduler.Task |
runTaskRepeatingAsync(Runnable runnable,
long delay,
long interval)
Schedule a repeating task to run asynchronously
|
static Scheduler.Task |
runTaskRepeatingSync(Consumer<Scheduler.Task> consumer,
long delay,
long interval)
Schedule a repeating task to run on the main server thread
|
static Scheduler.Task |
runTaskRepeatingSync(Runnable runnable,
long delay,
long interval)
Schedule a repeating task to run on the main server thread
|
static <T> Promise<T> |
supply(ThreadContext context,
Supplier<T> supplier)
Compute the result of the passed supplier
|
static <T> Promise<T> |
supplyAsync(Supplier<T> supplier)
Compute the result of the passed supplier asynchronously
|
static <T> Promise<T> |
supplyLater(ThreadContext context,
Supplier<T> supplier,
long delay)
Compute the result of the passed supplier at some point in the future
|
static <T> Promise<T> |
supplyLaterAsync(Supplier<T> supplier,
long delay)
Compute the result of the passed supplier asynchronously at some point in the future
|
static <T> Promise<T> |
supplyLaterSync(Supplier<T> supplier,
long delay)
Compute the result of the passed supplier on the main thread at some point in the future
|
static <T> Promise<T> |
supplySync(Supplier<T> supplier)
Compute the result of the passed supplier on the main thread
|
static Executor |
sync()
Returns a "sync" executor, which executes all passed runnables on the main server thread.
|
static Runnable |
wrapRunnable(Runnable runnable) |
public static Executor sync()
public static Executor async()
public static Executor bukkitAsync()
async(), which always uses the BukkitScheduler's
thread pool to execute tasks.
Note: the BukkitScheduler does not allow tasks to be posted if the backing plugin is not enabled. Execution of tasks does not commence until the server has fully started.
public static ExecutorService internalAsync()
async() which uses an internal thread pool
to execute tasks.
This executor instance is not affected by Bukkit rules, and will start working immediately. (before the server has fully started)
public static BukkitScheduler bukkit()
public static TaskBuilder builder()
TaskBuilder instancepublic static <T> Promise<T> supply(ThreadContext context, Supplier<T> supplier)
T - the return typecontext - the type of executor to use to supply the promisesupplier - the supplierpublic static <T> Promise<T> supplySync(Supplier<T> supplier)
T - the return typesupplier - the supplierpublic static <T> Promise<T> supplyAsync(Supplier<T> supplier)
T - the return typesupplier - the supplierpublic static <T> Promise<T> call(ThreadContext context, Callable<T> callable)
T - the return typecontext - the type of executor to use to supply the promisecallable - the callablepublic static <T> Promise<T> callSync(Callable<T> callable)
T - the return typecallable - the callablepublic static <T> Promise<T> callAsync(Callable<T> callable)
T - the return typecallable - the callablepublic static Promise<Void> run(ThreadContext context, Runnable runnable)
context - the type of executor to use to supply the promiserunnable - the runnablepublic static Promise<Void> runSync(Runnable runnable)
runnable - the runnablepublic static Promise<Void> runAsync(Runnable runnable)
runnable - the runnablepublic static <T> Consumer<T> consuming(ThreadContext context, Consumer<? super T> action)
T - the typecontext - the type of executor to use to supply the delegate consumeraction - the delegate consumerpublic static <T> Consumer<T> consumingSync(Consumer<? super T> action)
T - the typeaction - the delegate consumerpublic static <T> Consumer<T> consumingAsync(Consumer<? super T> action)
T - the typeaction - the delegate consumerpublic static <T> Promise<T> supplyLater(ThreadContext context, Supplier<T> supplier, long delay)
T - the return typecontext - the type of executor to use to supply the promisesupplier - the supplierdelay - the delay in ticks before calling the supplierpublic static <T> Promise<T> supplyLaterSync(Supplier<T> supplier, long delay)
T - the return typesupplier - the supplierdelay - the delay in ticks before calling the supplierpublic static <T> Promise<T> supplyLaterAsync(Supplier<T> supplier, long delay)
T - the return typesupplier - the supplierdelay - the delay in ticks before calling the supplierpublic static <T> Promise<T> callLater(ThreadContext context, Callable<T> callable, long delay)
T - the return typecontext - the type of executor to use to supply the promisecallable - the callabledelay - the delay in ticks before calling the supplierpublic static <T> Promise<T> callLaterSync(Callable<T> callable, long delay)
T - the return typecallable - the callabledelay - the delay in ticks before calling the supplierpublic static <T> Promise<T> callLaterAsync(Callable<T> callable, long delay)
T - the return typecallable - the callabledelay - the delay in ticks before calling the supplierpublic static Promise<Void> runLater(ThreadContext context, Runnable runnable, long delay)
context - the type of executor to use to supply the promiserunnable - the runnabledelay - the delay in ticks before calling the supplierpublic static Promise<Void> runLaterSync(Runnable runnable, long delay)
runnable - the runnabledelay - the delay in ticks before calling the supplierpublic static Promise<Void> runLaterAsync(Runnable runnable, long delay)
runnable - the runnabledelay - the delay in ticks before calling the supplierpublic static Scheduler.Task runTaskRepeating(ThreadContext context, Consumer<Scheduler.Task> consumer, long delay, long interval)
context - the type of executor to use to supply the promiseconsumer - the task to rundelay - the delay before the task beginsinterval - the interval at which the task will repeatpublic static Scheduler.Task runTaskRepeatingSync(Consumer<Scheduler.Task> consumer, long delay, long interval)
consumer - the task to rundelay - the delay before the task beginsinterval - the interval at which the task will repeatpublic static Scheduler.Task runTaskRepeatingAsync(Consumer<Scheduler.Task> consumer, long delay, long interval)
consumer - the task to rundelay - the delay before the task beginsinterval - the interval at which the task will repeatpublic static Scheduler.Task runTaskRepeating(ThreadContext context, Runnable runnable, long delay, long interval)
context - the type of executor to use to supply the promiserunnable - the task to rundelay - the delay before the task beginsinterval - the interval at which the task will repeatpublic static Scheduler.Task runTaskRepeatingSync(Runnable runnable, long delay, long interval)
runnable - the task to rundelay - the delay before the task beginsinterval - the interval at which the task will repeatpublic static Scheduler.Task runTaskRepeatingAsync(Runnable runnable, long delay, long interval)
runnable - the task to rundelay - the delay before the task beginsinterval - the interval at which the task will repeatCopyright © 2017. All rights reserved.