PerfCountersRef is a unique_ptr using a deleter that unregisters the
managed PerfCounters on deletion.
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
PerfCounters *m_perf_counters;
};
+class PerfCountersDeleter {
+ CephContext* cct;
+
+public:
+ PerfCountersDeleter() noexcept : cct(nullptr) {}
+ PerfCountersDeleter(CephContext* cct) noexcept : cct(cct) {}
+ void operator()(PerfCounters* p) noexcept {
+ if (cct)
+ cct->get_perfcounters_collection()->remove(p);
+ delete p;
+ }
+};
+
+using PerfCountersRef = std::unique_ptr<PerfCounters, PerfCountersDeleter>;
+
#endif