Class SchedulerExecutorPoolImpl

java.lang.Object
dev.rollczi.litecommands.scheduler.SchedulerExecutorPoolImpl
All Implemented Interfaces:
Scheduler

public class SchedulerExecutorPoolImpl extends Object implements Scheduler
  • Field Details

  • Constructor Details

    • SchedulerExecutorPoolImpl

      public SchedulerExecutorPoolImpl(String name)
    • SchedulerExecutorPoolImpl

      public SchedulerExecutorPoolImpl(String name, int pool)
  • Method Details

    • supplyLater

      public <T> CompletableFuture<T> supplyLater(SchedulerType type, Duration delay, ThrowingSupplier<T,Throwable> supplier)
      Description copied from interface: Scheduler
      Runs the supplier in the specified thread after the specified delay
      Specified by:
      supplyLater in interface Scheduler
      Type Parameters:
      T - the supplier return type
      Parameters:
      type - the thread type
      delay - the delay
      supplier - the supplier to run
      Returns:
      the supplier result
    • shutdown

      public void shutdown()
      Specified by:
      shutdown in interface Scheduler
    • createMainExecutor

      protected ExecutorService createMainExecutor(String name)
      Create the main executor. In some cases, the main executor might never be used. We don't want to have to create a useless thread This may look like a premature optimization, but a typical server has 40+ plugins As the framework spreads, more and more of them can use LiteCommands, so we better handle this situation, there are practically no losses anyway To improve performance executor set isMainThread to true.
      Returns:
      the main executor. (Should have one thread)
    • createAsyncExecutor

      protected ExecutorService createAsyncExecutor(String name, int pool)
      Create async executor.
      Returns:
      async executor.