# HG changeset patch # User Sebastien Jodogne # Date 1786622092 0 # Node ID 1159a299587c279431be20e000579fa5bdf6dc32 # Parent fc7b11559381d8d6e631522a26ff2956acb88a5d clarify how "ConcurrentJobs" option is handled diff -r fc7b11559381 -r 1159a299587c OrthancFramework/Sources/JobsEngine/JobsEngine.cpp --- a/OrthancFramework/Sources/JobsEngine/JobsEngine.cpp Thu Aug 13 11:45:02 2026 +0000 +++ b/OrthancFramework/Sources/JobsEngine/JobsEngine.cpp Thu Aug 13 11:54:52 2026 +0000 @@ -219,15 +219,22 @@ void JobsEngine::SetWorkersCount(size_t count) { - boost::mutex::scoped_lock lock(stateMutex_); - - if (state_ != State_Setup) + if (count == 0) { - // Can only be invoked before calling "Start()" - throw OrthancException(ErrorCode_BadSequenceOfCalls); + throw OrthancException(ErrorCode_ParameterOutOfRange); } - workers_.resize(count); + { + boost::mutex::scoped_lock lock(stateMutex_); + + if (state_ != State_Setup) + { + // Can only be invoked before calling "Start()" + throw OrthancException(ErrorCode_BadSequenceOfCalls); + } + + workers_.resize(count); + } } @@ -256,18 +263,7 @@ retryHandler_ = boost::thread(RetryHandler, this); - if (workers_.size() == 0) - { - // Use all the available CPUs - size_t n = boost::thread::hardware_concurrency(); - - if (n == 0) - { - n = 1; - } - - workers_.resize(n); - } + assert(!workers_.empty()); for (size_t i = 0; i < workers_.size(); i++) { diff -r fc7b11559381 -r 1159a299587c OrthancServer/Resources/Configuration.json --- a/OrthancServer/Resources/Configuration.json Thu Aug 13 11:45:02 2026 +0000 +++ b/OrthancServer/Resources/Configuration.json Thu Aug 13 11:54:52 2026 +0000 @@ -83,9 +83,9 @@ ], // Maximum number of processing jobs that are simultaneously running - // at any given time. A value of "0" indicates to use all the - // available CPU logical cores. To emulate Orthanc <= 1.3.2, set - // this value to "1". + // at any given time in the Orthanc jobs engine. A value of "0" + // indicates to use all the available CPU logical cores. To emulate + // Orthanc <= 1.3.2, set this value to "1". "ConcurrentJobs" : 2, diff -r fc7b11559381 -r 1159a299587c OrthancServer/Sources/OrthancConfiguration.cpp --- a/OrthancServer/Sources/OrthancConfiguration.cpp Thu Aug 13 11:45:02 2026 +0000 +++ b/OrthancServer/Sources/OrthancConfiguration.cpp Thu Aug 13 11:54:52 2026 +0000 @@ -1135,6 +1135,21 @@ } + unsigned int OrthancConfiguration::GetConcurrentJobs() const + { + unsigned int jobs = GetUnsignedIntegerParameter(ORTHANC_CONFIG_CONCURRENT_JOBS); + + if (jobs == 0) + { + return SystemToolbox::GetHardwareConcurrency(); + } + else + { + return jobs; + } + } + + void OrthancConfiguration::Format(std::string& result) const { Toolbox::WriteStyledJson(result, userConfiguration_); diff -r fc7b11559381 -r 1159a299587c OrthancServer/Sources/OrthancConfiguration.h --- a/OrthancServer/Sources/OrthancConfiguration.h Thu Aug 13 11:45:02 2026 +0000 +++ b/OrthancServer/Sources/OrthancConfiguration.h Thu Aug 13 11:54:52 2026 +0000 @@ -266,10 +266,7 @@ void RemovePeer(const std::string& symbolicName); - unsigned int GetConcurrentJobs() const - { - return GetUnsignedIntegerParameter(ORTHANC_CONFIG_CONCURRENT_JOBS); - } + unsigned int GetConcurrentJobs() const; unsigned int GetHttpThreadsCount() const { diff -r fc7b11559381 -r 1159a299587c OrthancServer/Sources/main.cpp --- a/OrthancServer/Sources/main.cpp Thu Aug 13 11:45:02 2026 +0000 +++ b/OrthancServer/Sources/main.cpp Thu Aug 13 11:54:52 2026 +0000 @@ -1665,7 +1665,7 @@ maxDcmtkConcurrentTranscoders = lock.GetConfiguration().GetUnsignedIntegerParameter(KEY_MAXIMUM_CONCURRENT_DCMTK_TRANSCODERS); if (maxDcmtkConcurrentTranscoders == 0) { - maxDcmtkConcurrentTranscoders = static_cast(boost::thread::hardware_concurrency()); + maxDcmtkConcurrentTranscoders = SystemToolbox::GetHardwareConcurrency(); } // Configuration of DICOM TLS for Orthanc SCU (since Orthanc 1.9.0)