# HG changeset patch # User Alain Mazy # Date 1778514884 -7200 # Node ID 8eea67b02a17ea995a0b3310156581d67284ab70 # Parent 18de08ccdd262915ea1cc9b01d54bd38f7730a13# Parent 78d2e3b2d40a378b13893c2466fca6bb568daf28 merge diff -r 18de08ccdd26 -r 8eea67b02a17 OrthancFramework/Sources/MultiThreading/ThreadPool.cpp --- 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 diff -r 18de08ccdd26 -r 8eea67b02a17 OrthancFramework/Sources/MultiThreading/ThreadPool.h --- 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 workers_; + boost::mutex mutex_; + unsigned int countThreads_; + State state_; + unsigned int dequeueTimeoutMilliseconds_; void StopInternal(bool throws); diff -r 18de08ccdd26 -r 8eea67b02a17 OrthancFramework/UnitTestsSources/JobsTests.cpp