From 5b8d61b2085349974716438b21776c4a975bc2fd Mon Sep 17 00:00:00 2001 From: Ricardo Antunes Date: Thu, 28 Mar 2024 11:50:26 +0000 Subject: [PATCH] refactor(core): move ThreadPool to new thread module --- core/CMakeLists.txt | 2 +- core/include/cubos/core/thread/module.dox | 13 +++++++++++++ .../cubos/core/{thread_pool.hpp => thread/pool.hpp} | 10 +++++----- core/src/{thread_pool.cpp => thread/pool.cpp} | 4 ++-- 4 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 core/include/cubos/core/thread/module.dox rename core/include/cubos/core/{thread_pool.hpp => thread/pool.hpp} (90%) rename core/src/{thread_pool.cpp => thread/pool.cpp} (95%) diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 46f53acbe..1f7cb8854 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -23,7 +23,7 @@ message("# Building core tests: " ${BUILD_CORE_TESTS}) # Set core source files set(CUBOS_CORE_SOURCE "src/log.cpp" - "src/thread_pool.cpp" + "src/thread/pool.cpp" "src/memory/stream.cpp" "src/memory/standard_stream.cpp" diff --git a/core/include/cubos/core/thread/module.dox b/core/include/cubos/core/thread/module.dox new file mode 100644 index 000000000..5ab782346 --- /dev/null +++ b/core/include/cubos/core/thread/module.dox @@ -0,0 +1,13 @@ +/// @dir +/// @brief @ref core-thread module. + +/// @namespace cubos::core::thread +/// @brief @ref core-thread module. +/// @ingroup core-thread + +namespace cubos::core::thread +{ + /// @defgroup core-thread Threading + /// @ingroup core + /// @brief Provides threading and asynchronous related utilities. +} // namespace cubos::core::thread diff --git a/core/include/cubos/core/thread_pool.hpp b/core/include/cubos/core/thread/pool.hpp similarity index 90% rename from core/include/cubos/core/thread_pool.hpp rename to core/include/cubos/core/thread/pool.hpp index 368474a49..74c041964 100644 --- a/core/include/cubos/core/thread_pool.hpp +++ b/core/include/cubos/core/thread/pool.hpp @@ -1,6 +1,6 @@ /// @file -/// @brief Class @ref cubos::core::ThreadPool. -/// @ingroup core +/// @brief Class @ref cubos::core::thread::ThreadPool. +/// @ingroup core-thread #pragma once @@ -11,11 +11,11 @@ #include #include -namespace cubos::core +namespace cubos::core::thread { /// @brief Manages a pool of threads, to which tasks can be submitted. /// @note Blocks on tasks to finish on destruction. - /// @ingroup core + /// @ingroup core-thread class ThreadPool final { public: @@ -49,4 +49,4 @@ namespace cubos::core std::atomic mNumTasks; ///< Number of tasks currently being executed. bool mStop; ///< Set to true when the thread pool is being destroyed. }; -} // namespace cubos::core +} // namespace cubos::core::thread diff --git a/core/src/thread_pool.cpp b/core/src/thread/pool.cpp similarity index 95% rename from core/src/thread_pool.cpp rename to core/src/thread/pool.cpp index 1632ae414..e010a6211 100644 --- a/core/src/thread_pool.cpp +++ b/core/src/thread/pool.cpp @@ -1,6 +1,6 @@ -#include +#include -using namespace cubos::core; +using cubos::core::thread::ThreadPool; ThreadPool::ThreadPool(std::size_t numThreads) {