instead of passing a copy, pass a reference. so we can save the overhead
of copying the function object.
Signed-off-by: Kefu Chai <kchai@redhat.com>
if (!pg->is_primary()) {
continue;
}
- pg->get_pg_stats([&](const pg_stat_t& s, epoch_t lec) {
+ pg->with_pg_stats([&](const pg_stat_t& s, epoch_t lec) {
m->pg_stat[pg->pg_id.pgid] = s;
min_last_epoch_clean = std::min(min_last_epoch_clean, lec);
min_last_epoch_clean_pgs.push_back(pg->pg_id.pgid);
}
}
-void PG::get_pg_stats(std::function<void(const pg_stat_t&, epoch_t lec)> f)
+void PG::with_pg_stats(std::function<void(const pg_stat_t&, epoch_t lec)>&& f)
{
std::lock_guard l{pg_stats_publish_lock};
if (pg_stats_publish) {
}
}
-void PG::with_heartbeat_peers(std::function<void(int)> f)
+void PG::with_heartbeat_peers(std::function<void(int)>&& f)
{
std::lock_guard l{heartbeat_peer_lock};
for (auto p : heartbeat_peers) {
void dump_pgstate_history(ceph::Formatter *f);
void dump_missing(ceph::Formatter *f);
- void get_pg_stats(std::function<void(const pg_stat_t&, epoch_t lec)> f);
- void with_heartbeat_peers(std::function<void(int)> f);
+ void with_pg_stats(std::function<void(const pg_stat_t&, epoch_t lec)>&& f);
+ void with_heartbeat_peers(std::function<void(int)>&& f);
void shutdown();
virtual void on_shutdown() = 0;