MCPcopy Create free account
hub / github.com/apache/arrow / ParseOMPEnvVar

Function ParseOMPEnvVar

cpp/src/arrow/util/thread_pool.cc:780–797  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

778// Global thread pool
779
780static int ParseOMPEnvVar(const char* name) {
781 // OMP_NUM_THREADS is a comma-separated list of positive integers.
782 // We are only interested in the first (top-level) number.
783 auto result = GetEnvVar(name);
784 if (!result.ok()) {
785 return 0;
786 }
787 auto str = *std::move(result);
788 auto first_comma = str.find_first_of(',');
789 if (first_comma != std::string::npos) {
790 str = str.substr(0, first_comma);
791 }
792 try {
793 return std::max(0, std::stoi(str));
794 } catch (...) {
795 return 0;
796 }
797}
798
799int ThreadPool::DefaultCapacity() {
800 int capacity = ParseOMPEnvVar("OMP_NUM_THREADS");

Callers 1

DefaultCapacityMethod · 0.85

Calls 3

GetEnvVarFunction · 0.85
substrMethod · 0.80
okMethod · 0.45

Tested by

no test coverage detected