From 34746766f79e5304ef4fa948e7e1d8a06bf8b816 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 31 Dec 2025 22:50:41 +0100 Subject: Add events count to EventHistory. --- src/lib/event_history.cc | 11 +++++++++++ src/lib/event_history.h | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/event_history.cc b/src/lib/event_history.cc index f68a6c9b9..b39a23d01 100644 --- a/src/lib/event_history.cc +++ b/src/lib/event_history.cc @@ -60,4 +60,15 @@ EventHistory::event() if (int(_history.size()) > _size) { _history.pop_back(); } + + ++_events; } + + +int +EventHistory::events() const +{ + boost::mutex::scoped_lock lock(_mutex); + return _events; +} + diff --git a/src/lib/event_history.h b/src/lib/event_history.h index 63329fa0e..5dd84cbbf 100644 --- a/src/lib/event_history.h +++ b/src/lib/event_history.h @@ -35,14 +35,16 @@ public: boost::optional rate() const; void event(); + int events() const; private: - /** Mutex for _history */ + /** Mutex for _history and _events */ mutable boost::mutex _mutex; /** List of the times of the last _history_size events first is the most recently completed. */ std::list _history; + int _events = 0; /** Number of events that we should keep history for */ int const _size; }; -- cgit v1.2.3