-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into sm-s3-unittest
- Loading branch information
Showing
43 changed files
with
1,598 additions
and
718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
Util/src/main/java/io/deephaven/util/thread/ThreadHelpers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// | ||
// Copyright (c) 2016-2024 Deephaven Data Labs and Patent Pending | ||
// | ||
package io.deephaven.util.thread; | ||
|
||
import io.deephaven.configuration.Configuration; | ||
|
||
public class ThreadHelpers { | ||
/** | ||
* Get the number of threads to use for a given configuration key, defaulting to the number of available processors | ||
* if the configuration key is set to a non-positive value, or the configuration key is not set and the provided | ||
* default is non-positive. | ||
* | ||
* @param configKey The configuration key to look up | ||
* @param defaultValue The default value to use if the configuration key is not set | ||
* @return The number of threads to use | ||
*/ | ||
public static int getOrComputeThreadCountProperty(final String configKey, final int defaultValue) { | ||
final int numThreads = Configuration.getInstance().getIntegerWithDefault(configKey, defaultValue); | ||
if (numThreads <= 0) { | ||
return Runtime.getRuntime().availableProcessors(); | ||
} else { | ||
return numThreads; | ||
} | ||
} | ||
} |
Oops, something went wrong.