From 624bdbcf3afe304ad043baca43d46bfda2746e78 Mon Sep 17 00:00:00 2001 From: John Spray Date: Wed, 9 Nov 2016 19:52:03 +0000 Subject: [PATCH] mgr: remove unnecessary C_StdFunction FunctionContext works fine and already existed. Signed-off-by: John Spray --- src/mgr/Mgr.cc | 2 +- src/mgr/MgrClient.cc | 2 +- src/mgr/MgrContext.h | 17 ----------------- src/mgr/MgrStandby.cc | 4 ++-- src/mgr/PyModules.cc | 4 ++-- src/mon/MgrMonitor.cc | 2 +- 6 files changed, 7 insertions(+), 24 deletions(-) diff --git a/src/mgr/Mgr.cc b/src/mgr/Mgr.cc index 653f131441840..7b7f24e62ab77 100644 --- a/src/mgr/Mgr.cc +++ b/src/mgr/Mgr.cc @@ -136,7 +136,7 @@ void Mgr::background_init() finisher.start(); - finisher.queue(new C_StdFunction([this](){ + finisher.queue(new FunctionContext([this](int r){ init(); })); } diff --git a/src/mgr/MgrClient.cc b/src/mgr/MgrClient.cc index 070de31c8e1f6..157baa9b8e215 100644 --- a/src/mgr/MgrClient.cc +++ b/src/mgr/MgrClient.cc @@ -229,7 +229,7 @@ void MgrClient::send_report() session->con->send_message(report); if (stats_period != 0) { - report_callback = new C_StdFunction([this](){send_report();}); + report_callback = new FunctionContext([this](int r){send_report();}); timer.add_event_after(stats_period, report_callback); } diff --git a/src/mgr/MgrContext.h b/src/mgr/MgrContext.h index eae7d756ae6b7..bb469b3a23054 100644 --- a/src/mgr/MgrContext.h +++ b/src/mgr/MgrContext.h @@ -15,27 +15,10 @@ #define MGR_CONTEXT_H_ #include -#include "include/Context.h" #include "common/ceph_json.h" #include "mon/MonClient.h" -class C_StdFunction : public Context -{ -private: - std::function fn; - -public: - C_StdFunction(std::function fn_) - : fn(fn_) - {} - - void finish(int r) - { - fn(); - } -}; - class Command { protected: diff --git a/src/mgr/MgrStandby.cc b/src/mgr/MgrStandby.cc index 0beb8937d76ca..fdaea9670c016 100644 --- a/src/mgr/MgrStandby.cc +++ b/src/mgr/MgrStandby.cc @@ -118,8 +118,8 @@ void MgrStandby::send_beacon() available); monc->send_mon_message(m); - timer.add_event_after(g_conf->mgr_beacon_period, new C_StdFunction( - [this](){ + timer.add_event_after(g_conf->mgr_beacon_period, new FunctionContext( + [this](int r){ send_beacon(); } )); diff --git a/src/mgr/PyModules.cc b/src/mgr/PyModules.cc index 35b6ed0687b6a..8599815363c81 100644 --- a/src/mgr/PyModules.cc +++ b/src/mgr/PyModules.cc @@ -437,7 +437,7 @@ void PyModules::shutdown() // Signal modules to drop out of serve() for (auto i : modules) { auto module = i.second; - finisher.queue(new C_StdFunction([module](){ + finisher.queue(new FunctionContext([module](int r){ module->shutdown(); })); } @@ -469,7 +469,7 @@ void PyModules::notify_all(const std::string ¬ify_type, auto module = i.second; // Send all python calls down a Finisher to avoid blocking // C++ code, and avoid any potential lock cycles. - finisher.queue(new C_StdFunction([module, notify_type, notify_id](){ + finisher.queue(new FunctionContext([module, notify_type, notify_id](int r){ module->notify(notify_type, notify_id); })); } diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index 8864f327a3c7a..ec3aaec11b21c 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -268,7 +268,7 @@ void MgrMonitor::send_digests() sub->session->con->send_message(mdigest); } - digest_callback = new C_StdFunction([this](){ + digest_callback = new FunctionContext([this](int r){ send_digests(); }); mon->timer.add_event_after(g_conf->mon_mgr_digest_period, digest_callback); -- 2.39.5