From dd8dc8105a4fc405f0269e0d32bc640047b94978 Mon Sep 17 00:00:00 2001 From: cohdan <145435761+cohdan@users.noreply.github.com> Date: Wed, 14 Feb 2024 21:48:44 +0200 Subject: [PATCH] Expose the flusher thread object to user in order to allow setting of thread name and thread affinity when needed (#3009) * Expose the flusher thread object to user in order to allow setting of thread name and thread affinity when needed * Code review fix - periodic_worker thread getter should return a reference and not a pointer --- include/spdlog/details/periodic_worker.h | 1 + include/spdlog/details/registry.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/spdlog/details/periodic_worker.h b/include/spdlog/details/periodic_worker.h index d38b1a94..a01f66a8 100644 --- a/include/spdlog/details/periodic_worker.h +++ b/include/spdlog/details/periodic_worker.h @@ -40,6 +40,7 @@ public: } }); } + std::thread &get_thread() { return worker_thread_; } periodic_worker(const periodic_worker &) = delete; periodic_worker &operator=(const periodic_worker &) = delete; // stop the worker thread and join it diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index 96d717e2..1eb9aa2f 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -66,6 +66,8 @@ public: periodic_flusher_ = std::make_unique(clbk, interval); } + std::unique_ptr &get_flusher() { std::lock_guard lock(flusher_mutex_); return periodic_flusher_; } + void set_error_handler(err_handler handler); void apply_all(const std::function)> &fun);