From 19fcec84d8d7d21e796c7624e521b60d28ee21ed Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:45:59 +0200 Subject: Adding upstream version 16.2.11+ds. Signed-off-by: Daniel Baumann --- src/common/perf_counters_collection.cc | 62 ++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/common/perf_counters_collection.cc (limited to 'src/common/perf_counters_collection.cc') diff --git a/src/common/perf_counters_collection.cc b/src/common/perf_counters_collection.cc new file mode 100644 index 000000000..d9af8a945 --- /dev/null +++ b/src/common/perf_counters_collection.cc @@ -0,0 +1,62 @@ +#include "common/perf_counters_collection.h" +#include "common/ceph_mutex.h" +#include "common/ceph_context.h" + +namespace ceph::common { +/* PerfcounterCollection hold the lock for PerfCounterCollectionImp */ +PerfCountersCollection::PerfCountersCollection(CephContext *cct) + : m_cct(cct), + m_lock(ceph::make_mutex("PerfCountersCollection")) +{ +} +PerfCountersCollection::~PerfCountersCollection() +{ + clear(); +} +void PerfCountersCollection::add(PerfCounters *l) +{ + std::lock_guard lck(m_lock); + perf_impl.add(l); +} +void PerfCountersCollection::remove(PerfCounters *l) +{ + std::lock_guard lck(m_lock); + perf_impl.remove(l); +} +void PerfCountersCollection::clear() +{ + std::lock_guard lck(m_lock); + perf_impl.clear(); +} +bool PerfCountersCollection::reset(const std::string &name) +{ + std::lock_guard lck(m_lock); + return perf_impl.reset(name); +} +void PerfCountersCollection::dump_formatted(ceph::Formatter *f, bool schema, + const std::string &logger, + const std::string &counter) +{ + std::lock_guard lck(m_lock); + perf_impl.dump_formatted(f,schema,logger,counter); +} +void PerfCountersCollection::dump_formatted_histograms(ceph::Formatter *f, bool schema, + const std::string &logger, + const std::string &counter) +{ + std::lock_guard lck(m_lock); + perf_impl.dump_formatted_histograms(f,schema,logger,counter); +} +void PerfCountersCollection::with_counters(std::function fn) const +{ + std::lock_guard lck(m_lock); + perf_impl.with_counters(fn); +} +void PerfCountersDeleter::operator()(PerfCounters* p) noexcept +{ + if (cct) + cct->get_perfcounters_collection()->remove(p); + delete p; +} + +} -- cgit v1.2.3