mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Use std::scoped_lock instead of std::lock_guard
This commit is contained in:
parent
b592b6c998
commit
66aefc6a54
1 changed files with 5 additions and 5 deletions
|
@ -149,7 +149,7 @@ public:
|
||||||
// arrivals (a push, is_push == true) and departures (a pull, is_push ==
|
// 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.
|
// false) as they happen. Note that this must not touch Zeek-side Vals.
|
||||||
void Observe(const broker::endpoint_id& peer, bool is_push) {
|
void Observe(const broker::endpoint_id& peer, bool is_push) {
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::scoped_lock<std::mutex> lock(mutex);
|
||||||
auto it = stats_map.find(peer);
|
auto it = stats_map.find(peer);
|
||||||
|
|
||||||
if ( it == stats_map.end() ) {
|
if ( it == stats_map.end() ) {
|
||||||
|
@ -186,7 +186,7 @@ public:
|
||||||
|
|
||||||
// Updates the internal table[string] of BrokerPeeringStats and returns it.
|
// Updates the internal table[string] of BrokerPeeringStats and returns it.
|
||||||
const zeek::TableValPtr& GetPeeringStatsTable() {
|
const zeek::TableValPtr& GetPeeringStatsTable() {
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::scoped_lock<std::mutex> lock(mutex);
|
||||||
|
|
||||||
for ( auto it = stats_map.begin(); it != stats_map.end(); ) {
|
for ( auto it = stats_map.begin(); it != stats_map.end(); ) {
|
||||||
auto& peer = it->first;
|
auto& peer = it->first;
|
||||||
|
@ -236,7 +236,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void RemovePeer(const broker::endpoint_id& peer) {
|
void RemovePeer(const broker::endpoint_id& peer) {
|
||||||
std::lock_guard<std::mutex> lock(mutex);
|
std::scoped_lock<std::mutex> lock(mutex);
|
||||||
if ( auto it = stats_map.find(peer); it != stats_map.end() )
|
if ( auto it = stats_map.find(peer); it != stats_map.end() )
|
||||||
it->second.is_zombie = true;
|
it->second.is_zombie = true;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,7 @@ public:
|
||||||
std::list<broker::event_ptr> tmp;
|
std::list<broker::event_ptr> tmp;
|
||||||
tmp.emplace_back(std::move(event));
|
tmp.emplace_back(std::move(event));
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::scoped_lock<std::mutex> lock(mutex_);
|
||||||
queue_.splice(queue_.end(), tmp);
|
queue_.splice(queue_.end(), tmp);
|
||||||
if ( queue_.size() == 1 ) {
|
if ( queue_.size() == 1 ) {
|
||||||
flare_.Fire();
|
flare_.Fire();
|
||||||
|
@ -281,7 +281,7 @@ public:
|
||||||
|
|
||||||
auto Drain() {
|
auto Drain() {
|
||||||
std::list<broker::event_ptr> events;
|
std::list<broker::event_ptr> events;
|
||||||
std::lock_guard<std::mutex> lock(mutex_);
|
std::scoped_lock<std::mutex> lock(mutex_);
|
||||||
if ( ! queue_.empty() ) {
|
if ( ! queue_.empty() ) {
|
||||||
queue_.swap(events);
|
queue_.swap(events);
|
||||||
flare_.Extinguish();
|
flare_.Extinguish();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue