Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancConfiguration.cpp @ 5130:f2dcdbe05884
ResourceModification jobs can now use multiple threads
author | Alain Mazy <am@osimis.io> |
---|---|
date | Thu, 05 Jan 2023 17:24:43 +0100 |
parents | 877bc3b96476 |
children | 0ea402b4d901 |
comparison
equal
deleted
inserted
replaced
5128:ede035d48b8e | 5130:f2dcdbe05884 |
---|---|
42 static const char* const ORTHANC_PEERS = "OrthancPeers"; | 42 static const char* const ORTHANC_PEERS = "OrthancPeers"; |
43 static const char* const ORTHANC_PEERS_IN_DB = "OrthancPeersInDatabase"; | 43 static const char* const ORTHANC_PEERS_IN_DB = "OrthancPeersInDatabase"; |
44 static const char* const TEMPORARY_DIRECTORY = "TemporaryDirectory"; | 44 static const char* const TEMPORARY_DIRECTORY = "TemporaryDirectory"; |
45 static const char* const DATABASE_SERVER_IDENTIFIER = "DatabaseServerIdentifier"; | 45 static const char* const DATABASE_SERVER_IDENTIFIER = "DatabaseServerIdentifier"; |
46 static const char* const WARNINGS = "Warnings"; | 46 static const char* const WARNINGS = "Warnings"; |
47 static const char* const JOBS_ENGINE_THREADS_COUNT = "JobsEngineThreadsCount"; | |
47 | 48 |
48 namespace Orthanc | 49 namespace Orthanc |
49 { | 50 { |
50 static void AddFileToConfiguration(Json::Value& target, | 51 static void AddFileToConfiguration(Json::Value& target, |
51 const boost::filesystem::path& path) | 52 const boost::filesystem::path& path) |
269 else | 270 else |
270 { | 271 { |
271 modalities_.clear(); | 272 modalities_.clear(); |
272 } | 273 } |
273 } | 274 } |
275 } | |
276 | |
277 void OrthancConfiguration::LoadJobsEngineThreadsCount() | |
278 { | |
279 // default values | |
280 jobsEngineThreadsCount_["ResourceModification"] = 1; | |
281 | |
282 if (json_.isMember(JOBS_ENGINE_THREADS_COUNT)) | |
283 { | |
284 const Json::Value& source = json_[JOBS_ENGINE_THREADS_COUNT]; | |
285 if (source.type() != Json::objectValue) | |
286 { | |
287 throw OrthancException(ErrorCode_BadFileFormat, | |
288 "Bad format of the \"" + std::string(JOBS_ENGINE_THREADS_COUNT) + | |
289 "\" configuration section"); | |
290 } | |
291 | |
292 Json::Value::Members members = source.getMemberNames(); | |
293 | |
294 for (size_t i = 0; i < members.size(); i++) | |
295 { | |
296 const std::string& name = members[i]; | |
297 if (!source[name].isUInt()) | |
298 { | |
299 throw OrthancException(ErrorCode_BadFileFormat, | |
300 "Bad format for \"" + std::string(JOBS_ENGINE_THREADS_COUNT) + "." + name + | |
301 "\". It should be an unsigned integer"); | |
302 } | |
303 jobsEngineThreadsCount_[name] = source[name].asUInt(); | |
304 } | |
305 } | |
306 } | |
307 | |
308 unsigned int OrthancConfiguration::GetJobsEngineWorkersThread(const std::string& jobType) const | |
309 { | |
310 unsigned int workersThread = 1; | |
311 | |
312 const JobsEngineThreadsCount::const_iterator it = jobsEngineThreadsCount_.find(jobType); | |
313 if (it != jobsEngineThreadsCount_.end()) | |
314 { | |
315 workersThread = it->second; | |
316 } | |
317 | |
318 if (workersThread == 0) | |
319 { | |
320 workersThread = SystemToolbox::GetHardwareConcurrency(); | |
321 } | |
322 | |
323 return workersThread; | |
274 } | 324 } |
275 | 325 |
276 void OrthancConfiguration::LoadPeers() | 326 void OrthancConfiguration::LoadPeers() |
277 { | 327 { |
278 if (GetBooleanParameter(ORTHANC_PEERS_IN_DB, false)) | 328 if (GetBooleanParameter(ORTHANC_PEERS_IN_DB, false)) |