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 committed by fearlessTobi
parent d5bcb45b2a
commit 21c71d21ae
21 changed files with 124 additions and 122 deletions

View file

@ -44,12 +44,12 @@ public:
}
void AddBackend(std::unique_ptr<Backend> backend) {
std::lock_guard<std::mutex> lock(writing_mutex);
std::lock_guard lock{writing_mutex};
backends.push_back(std::move(backend));
}
void RemoveBackend(std::string_view backend_name) {
std::lock_guard<std::mutex> lock(writing_mutex);
std::lock_guard lock{writing_mutex};
const auto it =
std::remove_if(backends.begin(), backends.end(),
[&backend_name](const auto& i) { return backend_name == i->GetName(); });
@ -78,7 +78,7 @@ private:
backend_thread = std::thread([&] {
Entry entry;
auto write_logs = [&](Entry& e) {
std::lock_guard<std::mutex> lock(writing_mutex);
std::lock_guard lock{writing_mutex};
for (const auto& backend : backends) {
backend->Write(e);
}