You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
514 B
C++

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#include "WaitReady.hxx"
#include "InputStream.hxx"
#include "CondHandler.hxx"
void
WaitReady(InputStream &is, std::unique_lock<Mutex> &lock)
{
CondInputStreamHandler handler;
const ScopeExchangeInputStreamHandler h{is, &handler};
handler.cond.wait(lock, [&is]{
is.Update();
return is.IsReady();
});
is.Check();
}
void
LockWaitReady(InputStream &is)
{
std::unique_lock lock{is.mutex};
WaitReady(is, lock);
}