use std::lock_guard instead of std::unique_lock (#3179)

This commit is contained in:
Leslie 2024-09-12 03:18:51 +08:00 committed by GitHub
parent 271f0f3b14
commit 2169a6f6ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -148,19 +148,19 @@ public:
#endif #endif
size_t overrun_counter() { size_t overrun_counter() {
std::unique_lock<std::mutex> lock(queue_mutex_); std::lock_guard<std::mutex> lock(queue_mutex_);
return q_.overrun_counter(); return q_.overrun_counter();
} }
size_t discard_counter() { return discard_counter_.load(std::memory_order_relaxed); } size_t discard_counter() { return discard_counter_.load(std::memory_order_relaxed); }
size_t size() { size_t size() {
std::unique_lock<std::mutex> lock(queue_mutex_); std::lock_guard<std::mutex> lock(queue_mutex_);
return q_.size(); return q_.size();
} }
void reset_overrun_counter() { void reset_overrun_counter() {
std::unique_lock<std::mutex> lock(queue_mutex_); std::lock_guard<std::mutex> lock(queue_mutex_);
q_.reset_overrun_counter(); q_.reset_overrun_counter();
} }