Merge pull request #11883 from jcsp/wip-mgr-functioncontext

mgr: remove unnecessary C_StdFunction

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2016-11-10 19:17:32 +08:00 committed by GitHub
commit a8cafa9553
6 changed files with 7 additions and 24 deletions

View File

@ -136,7 +136,7 @@ void Mgr::background_init()
finisher.start();
finisher.queue(new C_StdFunction([this](){
finisher.queue(new FunctionContext([this](int r){
init();
}));
}

View File

@ -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);
}

View File

@ -15,27 +15,10 @@
#define MGR_CONTEXT_H_
#include <memory>
#include "include/Context.h"
#include "common/ceph_json.h"
#include "mon/MonClient.h"
class C_StdFunction : public Context
{
private:
std::function<void()> fn;
public:
C_StdFunction(std::function<void()> fn_)
: fn(fn_)
{}
void finish(int r)
{
fn();
}
};
class Command
{
protected:

View File

@ -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();
}
));

View File

@ -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 &notify_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);
}));
}

View File

@ -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);