Class BalancedPrioritisedThreadPool

java.lang.Object
ca.spottedleaf.concurrentutil.executor.thread.BalancedPrioritisedThreadPool

public final class BalancedPrioritisedThreadPool extends Object
  • Field Details

    • DEFAULT_GROUP_TIME_SLICE

      public static final long DEFAULT_GROUP_TIME_SLICE
      See Also:
  • Constructor Details

    • BalancedPrioritisedThreadPool

      public BalancedPrioritisedThreadPool(long groupTimeSliceNS, Consumer<Thread> threadModifier)
  • Method Details

    • getAliveThreads

      public Thread[] getAliveThreads()
    • getCoreThreads

      public Thread[] getCoreThreads()
    • halt

      public void halt(boolean shutdownQueues)
      Prevents creation of new queues, shutdowns all non-shutdown queues if specified
    • join

      public boolean join(long msToWait)
      Waits until all threads in this pool have shutdown, or until the specified time has passed.
      Parameters:
      msToWait - Maximum time to wait.
      Returns:
      false if the maximum time passed, true otherwise.
    • joinInterruptable

      public boolean joinInterruptable(long msToWait) throws InterruptedException
      Waits until all threads in this pool have shutdown, or until the specified time has passed.
      Parameters:
      msToWait - Maximum time to wait.
      Returns:
      false if the maximum time passed, true otherwise.
      Throws:
      InterruptedException - If this thread is interrupted.
    • shutdown

      public void shutdown(boolean wait)
      Shuts down this thread pool, optionally waiting for all tasks to be executed. This function will invoke PrioritisedExecutor.shutdown() on all created executors on this thread pool.
      Parameters:
      wait - Whether to wait for tasks to be executed
    • adjustThreadCount

      public void adjustThreadCount(int threads)
    • createOrderedStreamGroup

      public BalancedPrioritisedThreadPool.OrderedStreamGroup createOrderedStreamGroup()
    • createOrderedStreamGroup

      public BalancedPrioritisedThreadPool.OrderedStreamGroup createOrderedStreamGroup(AtomicLong subOrderGenerate)