Class ADPScheduler


  • public abstract class ADPScheduler
    extends Object
    • Field Detail

      • poolName

        protected final String poolName
    • 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 execute
        delay - the later delay
        unit - 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 execute
        delay - the later delay
        period - the period between each execution
        unit - the unit of delay
        Returns:
        a cancellable task
      • shutdown

        public void shutdown()
        Shutdown the scheduler