thread/*Cond: rename methods to match std::condition_variable
This commit is contained in:
@@ -50,7 +50,7 @@ BufferedInputStream::~BufferedInputStream() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
stop = true;
|
||||
wake_cond.signal();
|
||||
wake_cond.notify_one();
|
||||
}
|
||||
|
||||
thread.Join();
|
||||
@@ -81,7 +81,7 @@ BufferedInputStream::Seek(offset_type new_offset)
|
||||
|
||||
seek_offset = new_offset;
|
||||
seek = true;
|
||||
wake_cond.signal();
|
||||
wake_cond.notify_one();
|
||||
|
||||
while (seek)
|
||||
client_cond.wait(mutex);
|
||||
@@ -123,21 +123,21 @@ BufferedInputStream::Read(void *ptr, size_t s)
|
||||
if (!IsAvailable()) {
|
||||
/* wake up the sleeping thread */
|
||||
idle = false;
|
||||
wake_cond.signal();
|
||||
wake_cond.notify_one();
|
||||
}
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
if (read_error) {
|
||||
wake_cond.signal();
|
||||
wake_cond.notify_one();
|
||||
std::rethrow_exception(std::exchange(read_error, {}));
|
||||
}
|
||||
|
||||
if (idle) {
|
||||
/* wake up the sleeping thread */
|
||||
idle = false;
|
||||
wake_cond.signal();
|
||||
wake_cond.notify_one();
|
||||
}
|
||||
|
||||
client_cond.wait(mutex);
|
||||
@@ -163,7 +163,7 @@ BufferedInputStream::RunThread() noexcept
|
||||
|
||||
idle = false;
|
||||
seek = false;
|
||||
client_cond.signal();
|
||||
client_cond.notify_one();
|
||||
} else if (!idle && !read_error &&
|
||||
input->IsAvailable() && !input->IsEOF()) {
|
||||
const auto read_offset = input->GetOffset();
|
||||
@@ -186,7 +186,7 @@ BufferedInputStream::RunThread() noexcept
|
||||
input->Seek(offset);
|
||||
} catch (...) {
|
||||
read_error = std::current_exception();
|
||||
client_cond.signal();
|
||||
client_cond.notify_one();
|
||||
InvokeOnAvailable();
|
||||
}
|
||||
}
|
||||
@@ -202,7 +202,7 @@ BufferedInputStream::RunThread() noexcept
|
||||
read_error = std::current_exception();
|
||||
}
|
||||
|
||||
client_cond.signal();
|
||||
client_cond.notify_one();
|
||||
InvokeOnAvailable();
|
||||
} else
|
||||
wake_cond.wait(mutex);
|
||||
|
@@ -99,7 +99,7 @@ public:
|
||||
}
|
||||
|
||||
void OnInputStreamAvailable() noexcept override {
|
||||
wake_cond.signal();
|
||||
wake_cond.notify_one();
|
||||
}
|
||||
|
||||
private:
|
||||
|
@@ -31,11 +31,11 @@ struct CondInputStreamHandler final : InputStreamHandler {
|
||||
|
||||
/* virtual methods from class InputStreamHandler */
|
||||
void OnInputStreamReady() noexcept override {
|
||||
cond.signal();
|
||||
cond.notify_one();
|
||||
}
|
||||
|
||||
void OnInputStreamAvailable() noexcept override {
|
||||
cond.signal();
|
||||
cond.notify_one();
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -46,7 +46,7 @@ ProxyInputStream::SetInput(InputStreamPtr _input) noexcept
|
||||
ready */
|
||||
CopyAttributes();
|
||||
|
||||
set_input_cond.signal();
|
||||
set_input_cond.notify_one();
|
||||
}
|
||||
|
||||
void
|
||||
|
@@ -46,7 +46,7 @@ ThreadInputStream::Stop() noexcept
|
||||
{
|
||||
const std::lock_guard<Mutex> lock(mutex);
|
||||
close = true;
|
||||
wake_cond.signal();
|
||||
wake_cond.notify_one();
|
||||
}
|
||||
|
||||
Cancel();
|
||||
@@ -145,7 +145,7 @@ ThreadInputStream::Read(void *ptr, size_t read_size)
|
||||
size_t nbytes = std::min(read_size, r.size);
|
||||
memcpy(ptr, r.data, nbytes);
|
||||
buffer.Consume(nbytes);
|
||||
wake_cond.broadcast();
|
||||
wake_cond.notify_all();
|
||||
offset += nbytes;
|
||||
return nbytes;
|
||||
}
|
||||
|
Reference in New Issue
Block a user