Mercurial > hg > orthanc
changeset 7094:1159a299587c streaming
clarify how "ConcurrentJobs" option is handled
| author | Sebastien Jodogne <s.jodogne@gmail.com> |
|---|---|
| date | Thu, 13 Aug 2026 11:54:52 +0000 |
| parents | fc7b11559381 |
| children | 1e78972b48fa |
| files | OrthancFramework/Sources/JobsEngine/JobsEngine.cpp OrthancServer/Resources/Configuration.json OrthancServer/Sources/OrthancConfiguration.cpp OrthancServer/Sources/OrthancConfiguration.h OrthancServer/Sources/main.cpp |
| diffstat | 5 files changed, 34 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- 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++) {
--- 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,
--- 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_);
--- 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 {
--- 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<unsigned int>(boost::thread::hardware_concurrency()); + maxDcmtkConcurrentTranscoders = SystemToolbox::GetHardwareConcurrency(); } // Configuration of DICOM TLS for Orthanc SCU (since Orthanc 1.9.0)
