From f4bc4be0fa812a042ec93d08987290fa40ae41b3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 10 Oct 2024 08:34:41 +0200 Subject: [PATCH] common/Finisher: add method get_thread_name() This allows eliminating the copy in `ActivePyModule`. Signed-off-by: Max Kellermann --- src/common/Finisher.h | 4 ++++ src/mgr/ActivePyModule.h | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/common/Finisher.h b/src/common/Finisher.h index c5c16052ff7..1a89f4289b7 100644 --- a/src/common/Finisher.h +++ b/src/common/Finisher.h @@ -113,6 +113,10 @@ class Finisher { bool is_empty(); + std::string_view get_thread_name() const noexcept { + return thread_name; + } + /// Construct an anonymous Finisher. /// Anonymous finishers do not log their queue length. explicit Finisher(CephContext *cct_); diff --git a/src/mgr/ActivePyModule.h b/src/mgr/ActivePyModule.h index 225a8edb4fc..8538f6e236a 100644 --- a/src/mgr/ActivePyModule.h +++ b/src/mgr/ActivePyModule.h @@ -48,7 +48,6 @@ private: std::string m_command_perms; const MgrSession* m_session = nullptr; - std::string fin_thread_name; public: Finisher finisher; // per active module finisher to execute commands @@ -56,8 +55,7 @@ public: ActivePyModule(const PyModuleRef &py_module_, LogChannelRef clog_) : PyModuleRunner(py_module_, clog_), - fin_thread_name(fmt::format("m-fin-{}", py_module->get_name()).substr(0,15)), - finisher(g_ceph_context, thread_name, fin_thread_name) + finisher(g_ceph_context, thread_name, fmt::format("m-fin-{}", py_module->get_name()).substr(0,15)) { } @@ -106,7 +104,7 @@ public: std::string_view get_fin_thread_name() const { - return fin_thread_name; + return finisher.get_thread_name(); } bool is_authorized(const std::map& arguments) const; -- 2.47.3