Class ADPScheduler
- java.lang.Object
-
- com.alessiodp.core.common.scheduling.ADPScheduler
-
public abstract class ADPScheduler extends Object
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedADPScheduler(@NotNull ADPPlugin plugin)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static Function<Throwable,? extends Void>exceptionally()ExecutorgetAsyncExecutor()Get asynchronous executorabstract ExecutorgetSyncExecutor()Get synchronous executorCompletableFuture<Void>runAsync(@NotNull Runnable runnable)Execute runnable asynchronously<T> CompletableFuture<T>runSupplyAsync(@NotNull Supplier<T> supplier)Execute supplier asynchronously and wait for responseCancellableTaskscheduleAsyncLater(@NotNull Runnable runnable, long delay, TimeUnit unit)Schedule a runnable to be performed laterCancellableTaskscheduleAsyncRepeating(@NotNull Runnable runnable, long delay, long period, TimeUnit unit)Schedule a runnable to be performed repeatedlyvoidshutdown()Shutdown the scheduler
-
-
-
Constructor Detail
-
ADPScheduler
protected ADPScheduler(@NotNull @NotNull ADPPlugin plugin)
-
-
Method Detail
-
getAsyncExecutor
public Executor getAsyncExecutor()
Get asynchronous executor- Returns:
- the asynchronous executor
-
getSyncExecutor
public abstract Executor getSyncExecutor()
Get synchronous executor- Returns:
- the synchronous server executor
-
runAsync
public CompletableFuture<Void> runAsync(@NotNull @NotNull Runnable runnable)
Execute runnable asynchronously- Parameters:
runnable- the runnable to execute- Returns:
- void
-
runSupplyAsync
public <T> CompletableFuture<T> runSupplyAsync(@NotNull @NotNull Supplier<T> supplier)
Execute supplier asynchronously and wait for response- Type Parameters:
T- the response type- Parameters:
supplier- the supplier to execute- Returns:
- the response of the supplier
-
scheduleAsyncLater
public CancellableTask scheduleAsyncLater(@NotNull @NotNull Runnable runnable, long delay, TimeUnit unit)
Schedule a runnable to be performed later- Parameters:
runnable- the runnable to executedelay- the later delayunit- the unit of delay- Returns:
- a cancellable task
-
scheduleAsyncRepeating
public CancellableTask scheduleAsyncRepeating(@NotNull @NotNull Runnable runnable, long delay, long period, TimeUnit unit)
Schedule a runnable to be performed repeatedly- Parameters:
runnable- the runnable to executedelay- the later delayperiod- the period between each executionunit- the unit of delay- Returns:
- a cancellable task
-
shutdown
public void shutdown()
Shutdown the scheduler
-
-