aboutsummaryrefslogtreecommitdiff
path: root/src/common/logging/backend.cpp
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-04-01 12:29:59 -0400
committerLioncash <mathew1800@gmail.com>2019-04-01 12:53:47 -0400
commiteb88e9d08851f1aeb4716d43f220a06880bf42eb (patch)
treeeaf2aabd5471c13fe89ac5f7da247b3bf1248e83 /src/common/logging/backend.cpp
parent86155dbb0041f65462474279c2a0b2a7b043d78f (diff)
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.
Diffstat (limited to 'src/common/logging/backend.cpp')
-rw-r--r--src/common/logging/backend.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index 4462ff3fbd..a03179520d 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -46,12 +46,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(); });
@@ -80,7 +80,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);
}