Skip to content

Commit f4bc4be

Browse files
committed
common/Finisher: add method get_thread_name()
This allows eliminating the copy in `ActivePyModule`. Signed-off-by: Max Kellermann <[email protected]>
1 parent 62ade6b commit f4bc4be

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/common/Finisher.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ class Finisher {
113113

114114
bool is_empty();
115115

116+
std::string_view get_thread_name() const noexcept {
117+
return thread_name;
118+
}
119+
116120
/// Construct an anonymous Finisher.
117121
/// Anonymous finishers do not log their queue length.
118122
explicit Finisher(CephContext *cct_);

src/mgr/ActivePyModule.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,14 @@ class ActivePyModule : public PyModuleRunner
4848

4949
std::string m_command_perms;
5050
const MgrSession* m_session = nullptr;
51-
std::string fin_thread_name;
5251
public:
5352
Finisher finisher; // per active module finisher to execute commands
5453

5554
public:
5655
ActivePyModule(const PyModuleRef &py_module_,
5756
LogChannelRef clog_)
5857
: PyModuleRunner(py_module_, clog_),
59-
fin_thread_name(fmt::format("m-fin-{}", py_module->get_name()).substr(0,15)),
60-
finisher(g_ceph_context, thread_name, fin_thread_name)
58+
finisher(g_ceph_context, thread_name, fmt::format("m-fin-{}", py_module->get_name()).substr(0,15))
6159

6260
{
6361
}
@@ -106,7 +104,7 @@ class ActivePyModule : public PyModuleRunner
106104

107105
std::string_view get_fin_thread_name() const
108106
{
109-
return fin_thread_name;
107+
return finisher.get_thread_name();
110108
}
111109

112110
bool is_authorized(const std::map<std::string, std::string>& arguments) const;

0 commit comments

Comments
 (0)