Class Configurations

java.lang.Object
org.flag4j.concurrency.Configurations

public final class Configurations extends Object
Configurations for standard and concurrent ops.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The default block size for blocked algorithms.
    static final int
    The default minimum recursive size for recursive algorithms.
    static final int
    The default number of threads to use for concurrent algorithms.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    Gets the current block size used in blocked algorithms.
    static int
    Gets the current number of threads to be used.
    static void
    Resets all configurations to their default values.
    static void
    setBlockSize(int blockSize)
    Sets the current block size used in blocked algorithms.
    static void
    setNumThreads(int numThreads)
    Sets the number of threads to use in concurrent algorithms.
    static int
    Sets the number of threads for use in concurrent ops as the number of processors available to the Java virtual machine.

    Methods inherited from class java.lang.Object

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

    • DEFAULT_NUM_THREADS

      public static final int DEFAULT_NUM_THREADS
      The default number of threads to use for concurrent algorithms.
    • DEFAULT_BLOCK_SIZE

      public static final int DEFAULT_BLOCK_SIZE
      The default block size for blocked algorithms.
      See Also:
    • DEFAULT_MIN_RECURSIVE_SIZE

      public static final int DEFAULT_MIN_RECURSIVE_SIZE
      The default minimum recursive size for recursive algorithms.
      See Also:
  • Method Details

    • setNumThreadsAsAvailableProcessors

      public static int setNumThreadsAsAvailableProcessors()
      Sets the number of threads for use in concurrent ops as the number of processors available to the Java virtual machine. Note that this value may change during runtime. This method will include logical cores so the value returned may be higher than the number of physical cores on the machine if hyper-threading is enabled.

      Returns:
      The new value of numThreads, i.e. the number of available processors.
    • getNumThreads

      public static int getNumThreads()
      Gets the current number of threads to be used.
      Returns:
      Current number of threads to use in concurrent algorithms.
    • setNumThreads

      public static void setNumThreads(int numThreads)
      Sets the number of threads to use in concurrent algorithms.
      Parameters:
      numThreads - Number of threads to use in concurrent algorithms.
    • getBlockSize

      public static int getBlockSize()
      Gets the current block size used in blocked algorithms. If it has not been changed it will default to 64.
      Returns:
      Current block size to use in concurrent algorithms.
    • setBlockSize

      public static void setBlockSize(int blockSize)
      Sets the current block size used in blocked algorithms.
      Parameters:
      blockSize - Block size to be used in concurrent algorithms.
    • resetAll

      public static void resetAll()
      Resets all configurations to their default values.