input/InputStreams: pass std::unique_lock<> to various methods

This commit is contained in:
Max Kellermann
2019-04-26 19:19:45 +02:00
parent 040573c636
commit 1b5c1f75a4
33 changed files with 212 additions and 156 deletions

View File

@@ -89,12 +89,13 @@ ProxyInputStream::Update() noexcept
}
void
ProxyInputStream::Seek(offset_type new_offset)
ProxyInputStream::Seek(std::unique_lock<Mutex> &lock,
offset_type new_offset)
{
while (!input)
set_input_cond.wait(mutex);
set_input_cond.wait(lock);
input->Seek(new_offset);
input->Seek(lock, new_offset);
CopyAttributes();
}
@@ -120,12 +121,13 @@ ProxyInputStream::IsAvailable() noexcept
}
size_t
ProxyInputStream::Read(void *ptr, size_t read_size)
ProxyInputStream::Read(std::unique_lock<Mutex> &lock,
void *ptr, size_t read_size)
{
while (!input)
set_input_cond.wait(mutex);
set_input_cond.wait(lock);
size_t nbytes = input->Read(ptr, read_size);
size_t nbytes = input->Read(lock, ptr, read_size);
CopyAttributes();
return nbytes;
}