input/buffering: move code to RunThreadLocked()

This commit is contained in:
Max Kellermann 2019-05-17 11:21:56 +02:00
parent 19e4672a54
commit 302c0515b7
2 changed files with 13 additions and 6 deletions

View File

@ -134,13 +134,9 @@ BufferingInputStream::FindFirstHole() const noexcept
return INVALID_OFFSET;
}
void
BufferingInputStream::RunThread() noexcept
inline void
BufferingInputStream::RunThreadLocked(std::unique_lock<Mutex> &lock) noexcept
{
SetThreadName("buffering");
std::unique_lock<Mutex> lock(mutex);
while (!stop) {
if (seek) {
try {
@ -256,6 +252,16 @@ BufferingInputStream::RunThread() noexcept
} else
wake_cond.wait(lock);
}
}
void
BufferingInputStream::RunThread() noexcept
{
SetThreadName("buffering");
std::unique_lock<Mutex> lock(mutex);
RunThreadLocked(lock);
/* clear the "input" attribute while holding the mutex */
auto _input = std::move(input);

View File

@ -88,6 +88,7 @@ protected:
private:
size_t FindFirstHole() const noexcept;
void RunThreadLocked(std::unique_lock<Mutex> &lock) noexcept;
void RunThread() noexcept;
/* virtual methods from class InputStreamHandler */