Skip to content

Commit

Permalink
[work] expose WorkGetConcurrencyLimitEnvSetting()
Browse files Browse the repository at this point in the history
  • Loading branch information
pmolodo committed Oct 19, 2024
1 parent 58058a8 commit 6a4f145
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pxr/base/work/threadLimits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ Work_NormalizeThreadCount(const int n)

// Returns the normalized thread limit value from the environment setting. Note
// that 0 means "no change", i.e. the environment setting does not apply.
static unsigned
Work_GetConcurrencyLimitSetting()
unsigned
WorkGetConcurrencyLimitEnvSetting()
{
return Work_NormalizeThreadCount(TfGetEnvSetting(PXR_WORK_THREAD_LIMIT));
}
Expand All @@ -106,7 +106,7 @@ Work_InitializeThreading()
{
// Get the thread limit from the environment setting. Note that this value
// can be 0, i.e. the environment setting does not apply.
const unsigned settingVal = Work_GetConcurrencyLimitSetting();
const unsigned settingVal = WorkGetConcurrencyLimitEnvSetting();

// Threading is initialized with maximum physical concurrency.
const unsigned physicalLimit = WorkGetPhysicalConcurrencyLimit();
Expand Down Expand Up @@ -147,7 +147,7 @@ WorkSetConcurrencyLimit(unsigned n)
if (n) {
// Get the thread limit from the environment setting. Note this value
// may be 0 (default).
const unsigned settingVal = Work_GetConcurrencyLimitSetting();
const unsigned settingVal = WorkGetConcurrencyLimitEnvSetting();

// Override n with the environment setting. This will make sure that the
// setting always wins over the specified value n, but only if the
Expand Down
7 changes: 7 additions & 0 deletions pxr/base/work/threadLimits.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ PXR_NAMESPACE_OPEN_SCOPE
///
WORK_API unsigned WorkGetConcurrencyLimit();

/// Return the value set via the PXR_WORK_THREAD_LIMIT env setting.
///
/// The returned value is always >= 0, and it is normalized according to the
/// rules in WorkSetConcurrencyLimitArgument.
///
WORK_API unsigned WorkGetConcurrencyLimitEnvSetting();

/// Return true if WorkGetPhysicalConcurrencyLimit() returns a number greater
/// than 1 and PXR_WORK_THREAD_LIMIT was not set in an attempt to limit the
/// process to a single thread, false otherwise.
Expand Down

0 comments on commit 6a4f145

Please sign in to comment.