thread/Cond: add wait() overload which takes a unique_lock<>

Just like std::condition_variable, which however has no way to specify
the std::mutex directly.
This commit is contained in:
Max Kellermann
2019-04-25 18:53:38 +02:00
parent b51bae5500
commit 92022658f9
18 changed files with 66 additions and 42 deletions

View File

@@ -149,7 +149,7 @@ BufferedInputStream::RunThread() noexcept
{
SetThreadName("input_buffered");
const std::lock_guard<Mutex> lock(mutex);
std::unique_lock<Mutex> lock(mutex);
while (!stop) {
assert(size == buffer.size());
@@ -205,6 +205,6 @@ BufferedInputStream::RunThread() noexcept
client_cond.notify_one();
InvokeOnAvailable();
} else
wake_cond.wait(mutex);
wake_cond.wait(lock);
}
}