Commit 3cd07d0b authored by Max Kellermann's avatar Max Kellermann

input/thread: use class ScopeLock and ScopeUnlock

parent 13259225
......@@ -28,10 +28,11 @@
ThreadInputStream::~ThreadInputStream()
{
Lock();
close = true;
wake_cond.signal();
Unlock();
{
const ScopeLock lock(mutex);
close = true;
wake_cond.signal();
}
Cancel();
......@@ -61,10 +62,10 @@ ThreadInputStream::ThreadFunc()
{
FormatThreadName("input:%s", plugin);
Lock();
const ScopeLock lock(mutex);
if (!Open(postponed_error)) {
cond.broadcast();
Unlock();
return;
}
......@@ -78,12 +79,14 @@ ThreadInputStream::ThreadFunc()
if (w.IsEmpty()) {
wake_cond.wait(mutex);
} else {
Unlock();
Error error;
size_t nbytes = ThreadRead(w.data, w.size, error);
size_t nbytes;
{
const ScopeUnlock unlock(mutex);
nbytes = ThreadRead(w.data, w.size, error);
}
Lock();
cond.broadcast();
if (nbytes == 0) {
......@@ -96,8 +99,6 @@ ThreadInputStream::ThreadFunc()
}
}
Unlock();
Close();
}
......
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