From 2c2b1eb921b8ef9647e4c7e389ed62c2b0a87742 Mon Sep 17 00:00:00 2001 From: Aster Seker Date: Tue, 16 Sep 2025 02:32:01 +0300 Subject: [PATCH] feat(config): add task executor ring capacity macro --- include/logit_cpp/logit/config.hpp | 11 +++++++++++ include/logit_cpp/logit/detail/TaskExecutor.hpp | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/logit_cpp/logit/config.hpp b/include/logit_cpp/logit/config.hpp index 211f5df..5c2acf1 100644 --- a/include/logit_cpp/logit/config.hpp +++ b/include/logit_cpp/logit/config.hpp @@ -168,6 +168,17 @@ /// \} +/// \name Task executor settings +/// Configuration options for the task executor implementation. +/// \{ + +/// \brief Default capacity for the task executor ring buffer when unlimited is requested. +#ifndef LOGIT_TASK_EXECUTOR_DEFAULT_RING_CAPACITY +#define LOGIT_TASK_EXECUTOR_DEFAULT_RING_CAPACITY 1024 +#endif + +/// \} + /// \} diff --git a/include/logit_cpp/logit/detail/TaskExecutor.hpp b/include/logit_cpp/logit/detail/TaskExecutor.hpp index 5090f1b..74280d3 100644 --- a/include/logit_cpp/logit/detail/TaskExecutor.hpp +++ b/include/logit_cpp/logit/detail/TaskExecutor.hpp @@ -5,6 +5,8 @@ /// \file TaskExecutor.hpp /// \brief Defines the TaskExecutor class, which manages task execution in a separate thread. +#include "../config.hpp" + #include #include #if defined(__EMSCRIPTEN__) && !defined(__EMSCRIPTEN_PTHREADS__) @@ -346,7 +348,7 @@ namespace logit { namespace detail { std::atomic m_dropped_tasks; ///< Number of discarded tasks due to overflow. std::atomic m_active_tasks; ///< Number of tasks currently running. - const std::size_t m_default_ring_cap = 1024; ///< Default capacity when unlimited requested. + const std::size_t m_default_ring_cap = LOGIT_TASK_EXECUTOR_DEFAULT_RING_CAPACITY; ///< Default capacity when unlimited requested. MpscRingAny> m_mpsc_queue; ///< Lock-free bounded MPSC ring. #ifdef LOGIT_ENABLE_DROP_OLDEST_SLOWPATH