From: Max Kellermann Date: Tue, 12 Aug 2025 09:11:39 +0000 (+0200) Subject: mon/MonClient: move inner class ContextVerter out of the header X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=70882016a73fdf86f12248ac53b08f8f693141fa;p=ceph.git mon/MonClient: move inner class ContextVerter out of the header Reduce compile times by compiling these start_mon_command() overloads only once. Signed-off-by: Max Kellermann --- diff --git a/src/mon/MonClient.cc b/src/mon/MonClient.cc index 2d486b0d11a3..05e73f4753bd 100644 --- a/src/mon/MonClient.cc +++ b/src/mon/MonClient.cc @@ -1380,6 +1380,57 @@ void MonClient::handle_command_reply(MCommandReply *reply) reply->put(); } +class MonClient::ContextVerter { + std::string* outs; + ceph::bufferlist* outbl; + Context* onfinish; + +public: + ContextVerter(std::string* outs, ceph::bufferlist* outbl, Context* onfinish) + : outs(outs), outbl(outbl), onfinish(onfinish) {} + ~ContextVerter() = default; + ContextVerter(const ContextVerter&) = default; + ContextVerter& operator =(const ContextVerter&) = default; + ContextVerter(ContextVerter&&) = default; + ContextVerter& operator =(ContextVerter&&) = default; + + void operator()(boost::system::error_code e, + std::string s, + ceph::bufferlist bl) { + if (outs) + *outs = std::move(s); + if (outbl) + *outbl = std::move(bl); + if (onfinish) + onfinish->complete(ceph::from_error_code(e)); + } +}; + +void MonClient::start_mon_command(std::vector&& cmd, bufferlist&& inbl, + bufferlist *outbl, std::string *outs, + Context *onfinish) +{ + start_mon_command(std::move(cmd), std::move(inbl), + ContextVerter(outs, outbl, onfinish)); +} + +void MonClient::start_mon_command(int mon_rank, std::vector&& cmd, + bufferlist&& inbl, bufferlist *outbl, std::string *outs, + Context *onfinish) +{ + start_mon_command(mon_rank, std::move(cmd), std::move(inbl), + ContextVerter(outs, outbl, onfinish)); +} + +void MonClient::start_mon_command(std::string&& mon_name, ///< mon name, with mon. prefix + std::vector&& cmd, bufferlist&& inbl, + bufferlist *outbl, std::string *outs, + Context *onfinish) +{ + start_mon_command(std::move(mon_name), std::move(cmd), std::move(inbl), + ContextVerter(outs, outbl, onfinish)); +} + int MonClient::_cancel_mon_command(uint64_t tid) { ceph_assert(ceph_mutex_is_locked(monc_lock)); diff --git a/src/mon/MonClient.h b/src/mon/MonClient.h index 3b78ea62ae27..e8e03049b264 100644 --- a/src/mon/MonClient.h +++ b/src/mon/MonClient.h @@ -721,52 +721,18 @@ public: }, consigned); } - class ContextVerter { - std::string* outs; - ceph::bufferlist* outbl; - Context* onfinish; - - public: - ContextVerter(std::string* outs, ceph::bufferlist* outbl, Context* onfinish) - : outs(outs), outbl(outbl), onfinish(onfinish) {} - ~ContextVerter() = default; - ContextVerter(const ContextVerter&) = default; - ContextVerter& operator =(const ContextVerter&) = default; - ContextVerter(ContextVerter&&) = default; - ContextVerter& operator =(ContextVerter&&) = default; - - void operator()(boost::system::error_code e, - std::string&& s, - ceph::bufferlist&& bl) { - if (outs) - *outs = std::move(s); - if (outbl) - *outbl = std::move(bl); - if (onfinish) - onfinish->complete(ceph::from_error_code(e)); - } - }; + class ContextVerter; - void start_mon_command(std::vector cmd, bufferlist&& inbl, + void start_mon_command(std::vector&& cmd, bufferlist&& inbl, bufferlist *outbl, std::string *outs, - Context *onfinish) { - start_mon_command(std::move(cmd), std::move(inbl), - ContextVerter(outs, outbl, onfinish)); - } + Context *onfinish); void start_mon_command(int mon_rank, std::vector&& cmd, bufferlist&& inbl, bufferlist *outbl, std::string *outs, - Context *onfinish) { - start_mon_command(mon_rank, std::move(cmd), std::move(inbl), - ContextVerter(outs, outbl, onfinish)); - } + Context *onfinish); void start_mon_command(std::string&& mon_name, ///< mon name, with mon. prefix std::vector&& cmd, bufferlist&& inbl, bufferlist *outbl, std::string *outs, - Context *onfinish) { - start_mon_command(std::move(mon_name), std::move(cmd), std::move(inbl), - ContextVerter(outs, outbl, onfinish)); - } - + Context *onfinish); // version requests public: