aboutsummaryrefslogtreecommitdiff
path: root/src/common/Threading/LockedQueue.h
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2025-11-30 14:25:32 +0100
committerShauren <shauren.trinity@gmail.com>2025-11-30 14:25:32 +0100
commit90be8fafb39469bd2c318c033e63294ebaad2ca4 (patch)
tree2d2d5424e54339b7581f9e224e909d6f08003136 /src/common/Threading/LockedQueue.h
parentd3f2aee245d62c70c940831531b17da821053f91 (diff)
Core/Misc: Use std::scoped_lock instead of unique_lock where possible (and old lock_guard)HEADmaster
Diffstat (limited to 'src/common/Threading/LockedQueue.h')
-rw-r--r--src/common/Threading/LockedQueue.h18
1 files changed, 9 insertions, 9 deletions
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<std::mutex> lock(_lock);
+ std::scoped_lock lock(_lock);
_queue.push_back(item);
}
//! Adds an item to the queue.
void add(T&& item)
{
- std::lock_guard<std::mutex> lock(_lock);
+ std::scoped_lock lock(_lock);
_queue.push_back(std::move(item));
}
@@ -54,14 +54,14 @@ public:
template<std::input_iterator Iterator>
void readd(Iterator begin, Iterator end)
{
- std::lock_guard<std::mutex> 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<std::mutex> lock(_lock);
+ std::scoped_lock lock(_lock);
if (_queue.empty())
return false;
@@ -73,7 +73,7 @@ public:
template<class Checker>
bool next(T& result, Checker& check)
{
- std::lock_guard<std::mutex> 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<std::mutex> lock(_lock);
+ std::scoped_lock lock(_lock);
_canceled = true;
}
//! Checks if the queue is cancelled.
bool cancelled()
{
- std::lock_guard<std::mutex> lock(_lock);
+ std::scoped_lock lock(_lock);
return _canceled;
}
///! Calls pop_front of the queue
void pop_front()
{
- std::lock_guard<std::mutex> 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<std::mutex> lock(_lock);
+ std::scoped_lock lock(_lock);
return _queue.empty();
}
};