From 90be8fafb39469bd2c318c033e63294ebaad2ca4 Mon Sep 17 00:00:00 2001 From: Shauren Date: Sun, 30 Nov 2025 14:25:32 +0100 Subject: Core/Misc: Use std::scoped_lock instead of unique_lock where possible (and old lock_guard) --- src/common/Threading/LockedQueue.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/common/Threading/LockedQueue.h') diff --git a/src/common/Threading/LockedQueue.h b/src/common/Threading/LockedQueue.h index 25666db9358..4a97da0c726 100644 --- a/src/common/Threading/LockedQueue.h +++ b/src/common/Threading/LockedQueue.h @@ -39,14 +39,14 @@ public: //! Adds an item to the queue. void add(T const& item) { - std::lock_guard lock(_lock); + std::scoped_lock lock(_lock); _queue.push_back(item); } //! Adds an item to the queue. void add(T&& item) { - std::lock_guard lock(_lock); + std::scoped_lock lock(_lock); _queue.push_back(std::move(item)); } @@ -54,14 +54,14 @@ public: template void readd(Iterator begin, Iterator end) { - std::lock_guard lock(_lock); + std::scoped_lock lock(_lock); _queue.insert(_queue.begin(), begin, end); } //! Gets the next result in the queue, if any. bool next(T& result) { - std::lock_guard lock(_lock); + std::scoped_lock lock(_lock); if (_queue.empty()) return false; @@ -73,7 +73,7 @@ public: template bool next(T& result, Checker& check) { - std::lock_guard lock(_lock); + std::scoped_lock lock(_lock); if (_queue.empty()) return false; @@ -89,28 +89,28 @@ public: //! Cancels the queue. void cancel() { - std::lock_guard lock(_lock); + std::scoped_lock lock(_lock); _canceled = true; } //! Checks if the queue is cancelled. bool cancelled() { - std::lock_guard lock(_lock); + std::scoped_lock lock(_lock); return _canceled; } ///! Calls pop_front of the queue void pop_front() { - std::lock_guard lock(_lock); + std::scoped_lock lock(_lock); _queue.pop_front(); } ///! Checks if we're empty or not with locks held bool empty() { - std::lock_guard lock(_lock); + std::scoped_lock lock(_lock); return _queue.empty(); } }; -- cgit v1.2.3