From 2984615f6a26c070cd29348b00ffc1a7480d4f06 Mon Sep 17 00:00:00 2001 From: Razvan Becheriu Date: Mon, 18 Nov 2019 19:56:35 +0200 Subject: [PATCH] [#883, !506] clean up code --- src/lib/util/thread_pool.h | 44 +++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lib/util/thread_pool.h b/src/lib/util/thread_pool.h index 78544f8e57..6016d6bb0c 100644 --- a/src/lib/util/thread_pool.h +++ b/src/lib/util/thread_pool.h @@ -63,18 +63,6 @@ struct ThreadPool { startInternal(thread_count); } - /// @brief start all the threads - /// - /// @param thread_count specifies the number of threads to be created and - /// started - void startInternal(uint32_t thread_count) { - queue_.enable(); - running_ = true; - for (uint32_t i = 0; i < thread_count; ++i) { - threads_.push_back(std::make_shared(&ThreadPool::run, this)); - } - } - /// @brief stop all the threads /// /// @throw InvalidOperation if thread pool already stopped @@ -85,16 +73,6 @@ struct ThreadPool { stopInternal(); } - /// @brief stop all the threads - void stopInternal() { - running_ = false; - queue_.disable(); - for (auto thread : threads_) { - thread->join(); - } - threads_.clear(); - } - /// @brief add a work item to the thread pool /// /// @param item the 'function' object to be added to the queue @@ -117,6 +95,28 @@ struct ThreadPool { } private: + /// @brief start all the threads + /// + /// @param thread_count specifies the number of threads to be created and + /// started + void startInternal(uint32_t thread_count) { + queue_.enable(); + running_ = true; + for (uint32_t i = 0; i < thread_count; ++i) { + threads_.push_back(std::make_shared(&ThreadPool::run, this)); + } + } + + /// @brief stop all the threads + void stopInternal() { + running_ = false; + queue_.disable(); + for (auto thread : threads_) { + thread->join(); + } + threads_.clear(); + } + /// @brief Defines a generic thread pool queue. /// /// The main purpose is to safely manage thread pool tasks. -- 2.47.2