diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 18:45:59 +0000 |
commit | 19fcec84d8d7d21e796c7624e521b60d28ee21ed (patch) | |
tree | 42d26aa27d1e3f7c0b8bd3fd14e7d7082f5008dc /src/common/perf_counters_collection.cc | |
parent | Initial commit. (diff) | |
download | ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.tar.xz ceph-19fcec84d8d7d21e796c7624e521b60d28ee21ed.zip |
Adding upstream version 16.2.11+ds.upstream/16.2.11+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/common/perf_counters_collection.cc')
-rw-r--r-- | src/common/perf_counters_collection.cc | 62 |
1 files changed, 62 insertions, 0 deletions
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<void(const PerfCountersCollectionImpl::CounterMap &)> 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; +} + +} |