changeset 6765:8eea67b02a17

merge
author Alain Mazy <am@orthanc.team>
date Mon, 11 May 2026 17:54:44 +0200
parents 18de08ccdd26 (current diff) 78d2e3b2d40a (diff)
children 1e3cecbb1310
files OrthancFramework/UnitTestsSources/JobsTests.cpp
diffstat 2 files changed, 13 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Sources/MultiThreading/ThreadPool.cpp	Mon May 11 17:52:49 2026 +0200
+++ b/OrthancFramework/Sources/MultiThreading/ThreadPool.cpp	Mon May 11 17:54:44 2026 +0200
@@ -133,7 +133,9 @@
       }
     }
 
-    workers_.join_all();
+    assert(workers_.get() != NULL);
+    workers_->join_all();
+    workers_.reset(NULL);
 
     // Cancel all the remaining tasks in the queue
     for (;;)
@@ -270,9 +272,12 @@
 
       state_ = State_Running;
 
+      assert(workers_.get() == NULL);
+      workers_.reset(new boost::thread_group);
+
       for (unsigned int i = 0; i < countThreads_; i++)
       {
-        workers_.create_thread(boost::bind(&ThreadPool::WorkerLoop, this));
+        workers_->create_thread(boost::bind(&ThreadPool::WorkerLoop, this));
       }
     }
     else
--- a/OrthancFramework/Sources/MultiThreading/ThreadPool.h	Mon May 11 17:52:49 2026 +0200
+++ b/OrthancFramework/Sources/MultiThreading/ThreadPool.h	Mon May 11 17:54:44 2026 +0200
@@ -44,12 +44,12 @@
 
     class Task;
 
-    SharedMessageQueue   queue_;
-    boost::thread_group  workers_;
-    boost::mutex         mutex_;
-    unsigned int         countThreads_;
-    State                state_;
-    unsigned int         dequeueTimeoutMilliseconds_;
+    SharedMessageQueue                    queue_;
+    std::unique_ptr<boost::thread_group>  workers_;
+    boost::mutex                          mutex_;
+    unsigned int                          countThreads_;
+    State                                 state_;
+    unsigned int                          dequeueTimeoutMilliseconds_;
 
     void StopInternal(bool throws);