From 66aefc6a54f4e412bb9382c4c7490cc7dbffb01d Mon Sep 17 00:00:00 2001 From: Tim Wojtulewicz Date: Tue, 2 Sep 2025 16:41:37 +0000 Subject: [PATCH] Use std::scoped_lock instead of std::lock_guard --- src/broker/Manager.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index d9335e838f..cd4d0c8788 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -149,7 +149,7 @@ public: // arrivals (a push, is_push == true) and departures (a pull, is_push == // false) as they happen. Note that this must not touch Zeek-side Vals. void Observe(const broker::endpoint_id& peer, bool is_push) { - std::lock_guard lock(mutex); + std::scoped_lock lock(mutex); auto it = stats_map.find(peer); if ( it == stats_map.end() ) { @@ -186,7 +186,7 @@ public: // Updates the internal table[string] of BrokerPeeringStats and returns it. const zeek::TableValPtr& GetPeeringStatsTable() { - std::lock_guard lock(mutex); + std::scoped_lock lock(mutex); for ( auto it = stats_map.begin(); it != stats_map.end(); ) { auto& peer = it->first; @@ -236,7 +236,7 @@ public: } void RemovePeer(const broker::endpoint_id& peer) { - std::lock_guard lock(mutex); + std::scoped_lock lock(mutex); if ( auto it = stats_map.find(peer); it != stats_map.end() ) it->second.is_zombie = true; } @@ -271,7 +271,7 @@ public: std::list tmp; tmp.emplace_back(std::move(event)); { - std::lock_guard lock(mutex_); + std::scoped_lock lock(mutex_); queue_.splice(queue_.end(), tmp); if ( queue_.size() == 1 ) { flare_.Fire(); @@ -281,7 +281,7 @@ public: auto Drain() { std::list events; - std::lock_guard lock(mutex_); + std::scoped_lock lock(mutex_); if ( ! queue_.empty() ) { queue_.swap(events); flare_.Extinguish();