general: Use deducation guides for std::lock_guard and std::unique_lock

Since C++17, the introduction of deduction guides for locking facilities
means that we no longer need to hardcode the mutex type into the locks
themselves, making it easier to switch mutex types, should it ever be
necessary in the future.
This commit is contained in:
Lioncash 2019-04-01 12:29:59 -04:00
parent d9b7bc4474
commit 781ab8407b
23 changed files with 77 additions and 75 deletions

View file

@ -78,7 +78,7 @@ public:
T PopWait() {
if (Empty()) {
std::unique_lock<std::mutex> lock(cv_mutex);
std::unique_lock lock{cv_mutex};
cv.wait(lock, [this]() { return !Empty(); });
}
T t;
@ -137,7 +137,7 @@ public:
template <typename Arg>
void Push(Arg&& t) {
std::lock_guard<std::mutex> lock(write_lock);
std::lock_guard lock{write_lock};
spsc_queue.Push(t);
}