diff options
author | Max Kellermann <max@musicpd.org> | 2019-04-25 19:23:52 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2019-04-25 19:44:59 +0200 |
commit | d38a079ba1bec387c8a6eaa34d88df53380b2c49 (patch) | |
tree | 22773e20b562d22b6e65a05543f78ce4e5624cf1 /src/neighbor | |
parent | c75a0f7c753047b135a71cb679c8bfbe7da40f76 (diff) |
neighbor/smbclient: use std::lock_guard
Diffstat (limited to 'src/neighbor')
-rw-r--r-- | src/neighbor/plugins/SmbclientNeighborPlugin.cxx | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/neighbor/plugins/SmbclientNeighborPlugin.cxx b/src/neighbor/plugins/SmbclientNeighborPlugin.cxx index be944b0ec..71e94266a 100644 --- a/src/neighbor/plugins/SmbclientNeighborPlugin.cxx +++ b/src/neighbor/plugins/SmbclientNeighborPlugin.cxx @@ -94,10 +94,11 @@ SmbclientNeighborExplorer::Open() void SmbclientNeighborExplorer::Close() noexcept { - mutex.lock(); - quit = true; - cond.signal(); - mutex.unlock(); + { + const std::lock_guard<Mutex> lock(mutex); + quit = true; + cond.signal(); + } thread.Join(); } @@ -237,7 +238,7 @@ SmbclientNeighborExplorer::ThreadFunc() noexcept { SetThreadName("smbclient"); - mutex.lock(); + const std::lock_guard<Mutex> lock(mutex); while (!quit) { Run(); @@ -248,8 +249,6 @@ SmbclientNeighborExplorer::ThreadFunc() noexcept // TODO: sleep for how long? cond.timed_wait(mutex, std::chrono::seconds(10)); } - - mutex.unlock(); } static std::unique_ptr<NeighborExplorer> |