# HG changeset patch # User Sebastien Jodogne # Date 1786698376 -7200 # Node ID 2f62c814aee2b18008072a3b13a743c01ab181fa # Parent c155dfa1de8e6a843b4cda26c524fa0b49724b2c making MetricsRegistry compatible with wasm diff -r c155dfa1de8e -r 2f62c814aee2 OrthancFramework/Sources/MetricsRegistry.cpp --- a/OrthancFramework/Sources/MetricsRegistry.cpp Fri Aug 14 10:12:33 2026 +0200 +++ b/OrthancFramework/Sources/MetricsRegistry.cpp Fri Aug 14 11:06:16 2026 +0200 @@ -403,7 +403,7 @@ void MetricsRegistry::SetEnabled(bool enabled) { - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); enabled_ = enabled; } @@ -412,7 +412,7 @@ MetricsUpdatePolicy policy, MetricsDataType type) { - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); if (content_.find(name) != content_.end()) { @@ -472,7 +472,7 @@ // Inlining to avoid loosing time if metrics are disabled if (enabled_) { - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); GetItemInternal(name, policy, MetricsDataType_Float).UpdateFloat(value); } } @@ -485,7 +485,7 @@ // Inlining to avoid loosing time if metrics are disabled if (enabled_) { - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); GetItemInternal(name, policy, MetricsDataType_Integer).UpdateInteger(value); } } @@ -497,7 +497,7 @@ // Inlining to avoid loosing time if metrics are disabled if (enabled_) { - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); GetItemInternal(name, MetricsUpdatePolicy_Directly, MetricsDataType_Integer).IncrementInteger(delta); } } @@ -507,7 +507,7 @@ { if (enabled_) { - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); GetItemInternal(name, MetricsUpdatePolicy_Directly, MetricsDataType_Integer).SetInitialValue(value); } } @@ -515,7 +515,7 @@ MetricsUpdatePolicy MetricsRegistry::GetUpdatePolicy(const std::string& metrics) { - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); Content::const_iterator found = content_.find(metrics); @@ -533,7 +533,7 @@ MetricsDataType MetricsRegistry::GetDataType(const std::string& metrics) { - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); Content::const_iterator found = content_.find(metrics); @@ -554,7 +554,7 @@ // https://www.boost.org/doc/libs/1_69_0/doc/html/date_time/examples.html#date_time.examples.seconds_since_epoch static const boost::posix_time::ptime EPOCH(boost::gregorian::date(1970, 1, 1)); - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); s.clear(); @@ -600,14 +600,14 @@ void MetricsRegistry::SharedMetrics::Add(int64_t delta) { - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); value_ += delta; registry_.SetIntegerValue(name_, value_); } void MetricsRegistry::SharedMetrics::SetInitialValue(int64_t value) { - boost::mutex::scoped_lock lock(mutex_); + Mutex::ScopedLock lock(mutex_); value_ = value; registry_.SetInitialValue(name_, value_); } diff -r c155dfa1de8e -r 2f62c814aee2 OrthancFramework/Sources/MetricsRegistry.h --- a/OrthancFramework/Sources/MetricsRegistry.h Fri Aug 14 10:12:33 2026 +0200 +++ b/OrthancFramework/Sources/MetricsRegistry.h Fri Aug 14 11:06:16 2026 +0200 @@ -30,12 +30,9 @@ # error The macro ORTHANC_SANDBOXED must be defined #endif -#if ORTHANC_SANDBOXED == 1 -# error The class MetricsRegistry cannot be used in sandboxed environments -#endif +#include "MultiThreading/Mutex.h" #include -#include #include #include @@ -67,7 +64,7 @@ typedef std::map Content; bool enabled_; - boost::mutex mutex_; + Mutex mutex_; Content content_; // The mutex must be locked @@ -125,7 +122,7 @@ class ORTHANC_PUBLIC SharedMetrics : public boost::noncopyable { private: - boost::mutex mutex_; + Mutex mutex_; MetricsRegistry& registry_; std::string name_; int64_t value_;