mirror of
https://github.com/ceph/ceph
synced 2024-12-29 15:03:33 +00:00
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:
commit
a8cafa9553
@ -136,7 +136,7 @@ void Mgr::background_init()
|
||||
|
||||
finisher.start();
|
||||
|
||||
finisher.queue(new C_StdFunction([this](){
|
||||
finisher.queue(new FunctionContext([this](int r){
|
||||
init();
|
||||
}));
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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:
|
||||
|
@ -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();
|
||||
}
|
||||
));
|
||||
|
@ -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);
|
||||
}));
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user