Package org.flag4j.concurrency
Class Configurations
java.lang.Object
org.flag4j.concurrency.Configurations
Configurations for standard and concurrent operations.
-
Field Summary
Modifier and TypeFieldDescriptionprivate static int
The block size to use in blocked algorithms.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. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
Gets the current block size used in blocked algorithms.static int
Gets the current number of threads to be used.static void
resetAll()
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 operations as the number of processors available to the Java virtual machine.
-
Field Details
-
DEFAULT_NUM_THREADS
public static final int DEFAULT_NUM_THREADSThe default number of threads to use for concurrent algorithms. -
DEFAULT_BLOCK_SIZE
public static final int DEFAULT_BLOCK_SIZEThe default block size for blocked algorithms.- See Also:
-
DEFAULT_MIN_RECURSIVE_SIZE
public static final int DEFAULT_MIN_RECURSIVE_SIZEThe default minimum recursive size for recursive algorithms.- See Also:
-
blockSize
private static int blockSizeThe block size to use in blocked algorithms.
-
-
Constructor Details
-
Configurations
private Configurations()
-
-
Method Details
-
setNumThreadsAsAvailableProcessors
public static int setNumThreadsAsAvailableProcessors()Sets the number of threads for use in concurrent operations 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 willdefault 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.
-