changeset 5150:6ff13c95f62f

ThreadedSetOfInstancesJob: reduce cpu consumption of job main thread
author Alain Mazy <am@osimis.io>
date Mon, 30 Jan 2023 11:31:12 +0100
parents 2df546a76e17
children a72e00a23191
files OrthancServer/Sources/ServerJobs/ThreadedSetOfInstancesJob.cpp
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/Sources/ServerJobs/ThreadedSetOfInstancesJob.cpp	Fri Jan 27 12:56:55 2023 +0100
+++ b/OrthancServer/Sources/ServerJobs/ThreadedSetOfInstancesJob.cpp	Mon Jan 30 11:31:12 2023 +0100
@@ -156,6 +156,9 @@
         // wait until all instances are processed by the workers
         if (instancesToProcessQueue_.GetSize() != 0)
         {
+          // "slow down" the job main thread, to avoid using 100% of a core simply to check that other threads are done
+          boost::this_thread::sleep(boost::posix_time::milliseconds(5));
+
           return JobStepResult::Continue();
         }
         else