Commit d38a079b authored by Max Kellermann's avatar Max Kellermann

neighbor/smbclient: use std::lock_guard

parent c75a0f7c
...@@ -94,10 +94,11 @@ SmbclientNeighborExplorer::Open() ...@@ -94,10 +94,11 @@ SmbclientNeighborExplorer::Open()
void void
SmbclientNeighborExplorer::Close() noexcept SmbclientNeighborExplorer::Close() noexcept
{ {
mutex.lock(); {
const std::lock_guard<Mutex> lock(mutex);
quit = true; quit = true;
cond.signal(); cond.signal();
mutex.unlock(); }
thread.Join(); thread.Join();
} }
...@@ -237,7 +238,7 @@ SmbclientNeighborExplorer::ThreadFunc() noexcept ...@@ -237,7 +238,7 @@ SmbclientNeighborExplorer::ThreadFunc() noexcept
{ {
SetThreadName("smbclient"); SetThreadName("smbclient");
mutex.lock(); const std::lock_guard<Mutex> lock(mutex);
while (!quit) { while (!quit) {
Run(); Run();
...@@ -248,8 +249,6 @@ SmbclientNeighborExplorer::ThreadFunc() noexcept ...@@ -248,8 +249,6 @@ SmbclientNeighborExplorer::ThreadFunc() noexcept
// TODO: sleep for how long? // TODO: sleep for how long?
cond.timed_wait(mutex, std::chrono::seconds(10)); cond.timed_wait(mutex, std::chrono::seconds(10));
} }
mutex.unlock();
} }
static std::unique_ptr<NeighborExplorer> static std::unique_ptr<NeighborExplorer>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment