Class ExecutorUtils


  • public final class ExecutorUtils
    extends java.lang.Object
    Utilities for executors and sizing them.
    Since:
    1.9.5
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.util.concurrent.Executor DIRECT_EXECUTOR
      Shared instance of "direct executor".
    • Constructor Summary

      Constructors 
      Constructor Description
      ExecutorUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.concurrent.Executor executor​(int size, java.lang.String namePrefix)
      Returns DIRECT_EXECUTOR or result of threadPool(int, String) depending on value of size parameter.
      static void shutdown​(java.util.concurrent.Executor executor)
      To be used with result of executor(int, String) method, shuts down instance if it is ExecutorService.
      static int threadCount​(org.eclipse.aether.RepositorySystemSession session, int defaultValue, java.lang.String... keys)
      Retrieves and validates requested thread count based on session and specified keys, or if none provided, the provided default value.
      static java.util.concurrent.ExecutorService threadPool​(int poolSize, java.lang.String namePrefix)
      Creates new thread pool ExecutorService.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DIRECT_EXECUTOR

        public static final java.util.concurrent.Executor DIRECT_EXECUTOR
        Shared instance of "direct executor".
    • Method Detail

      • threadPool

        public static java.util.concurrent.ExecutorService threadPool​(int poolSize,
                                                                      java.lang.String namePrefix)
        Creates new thread pool ExecutorService. The poolSize parameter but be greater than 1.
      • shutdown

        public static void shutdown​(java.util.concurrent.Executor executor)
        To be used with result of executor(int, String) method, shuts down instance if it is ExecutorService.
      • threadCount

        public static int threadCount​(org.eclipse.aether.RepositorySystemSession session,
                                      int defaultValue,
                                      java.lang.String... keys)
        Retrieves and validates requested thread count based on session and specified keys, or if none provided, the provided default value. This method validates result on top of what ConfigUtils does.
        Throws:
        java.lang.IllegalArgumentException - if default value is less than 1.
        See Also:
        ConfigUtils.getInteger(RepositorySystemSession, int, String...)