Cleanup / optimizations
This commit is contained in:
@@ -6,18 +6,19 @@
|
||||
template <typename T> struct Queue {
|
||||
void push(T val) {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
q.push(val);
|
||||
q.push(std::move(val));
|
||||
}
|
||||
std::optional<T> front() {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
if (q.empty())
|
||||
return std::nullopt;
|
||||
return q.front();
|
||||
return std::move(q.front());
|
||||
}
|
||||
bool pop(T &val) {
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
if (q.empty())
|
||||
return false;
|
||||
val = q.front();
|
||||
val = std::move(q.front());
|
||||
q.pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user