]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/Finisher: add method get_thread_name()
authorMax Kellermann <max.kellermann@ionos.com>
Thu, 10 Oct 2024 06:34:41 +0000 (08:34 +0200)
committerMax Kellermann <max.kellermann@ionos.com>
Thu, 10 Oct 2024 06:55:31 +0000 (08:55 +0200)
This allows eliminating the copy in `ActivePyModule`.

Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
src/common/Finisher.h
src/mgr/ActivePyModule.h

index c5c16052ff7c8e68883f26f069cd2eef5a3705b0..1a89f4289b71573475b086b756ed1381e222d8a5 100644 (file)
@@ -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_);
index 225a8edb4fcaca76bac515dc7289e4397168cf90..8538f6e236a3736dc44d3595f81379d7806d1f7d 100644 (file)
@@ -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<std::string, std::string>& arguments) const;