From af4ffa91fd1350b9cf6b30f7ce5384f92e5739c6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 20 Aug 2019 19:23:44 +0200 Subject: [PATCH] decoder/Control: remove attribute `client_is_waiting` This optimization is useless because sane pthread_cond_signal() implementations check the number of waiters and do not invoke a system call if there are none. --- src/decoder/Bridge.cxx | 3 +-- src/decoder/Control.cxx | 6 ------ src/decoder/Control.hxx | 7 ------- 3 files changed, 1 insertion(+), 15 deletions(-) diff --git a/src/decoder/Bridge.cxx b/src/decoder/Bridge.cxx index 6d39efd7d..6fd2fbb23 100644 --- a/src/decoder/Bridge.cxx +++ b/src/decoder/Bridge.cxx @@ -145,8 +145,7 @@ DecoderBridge::FlushChunk() noexcept dc.pipe->Push(std::move(chunk)); const std::lock_guard protect(dc.mutex); - if (dc.client_is_waiting) - dc.client_cond.notify_one(); + dc.client_cond.notify_one(); } bool diff --git a/src/decoder/Control.cxx b/src/decoder/Control.cxx index 6795fd01c..7d80d181f 100644 --- a/src/decoder/Control.cxx +++ b/src/decoder/Control.cxx @@ -43,13 +43,7 @@ DecoderControl::~DecoderControl() noexcept void DecoderControl::WaitForDecoder(std::unique_lock &lock) noexcept { - assert(!client_is_waiting); - client_is_waiting = true; - client_cond.wait(lock); - - assert(client_is_waiting); - client_is_waiting = false; } void diff --git a/src/decoder/Control.hxx b/src/decoder/Control.hxx index ee9dde73b..363a77282 100644 --- a/src/decoder/Control.hxx +++ b/src/decoder/Control.hxx @@ -111,13 +111,6 @@ private: bool quit; public: - /** - * Is the client currently waiting for the DecoderThread? If - * false, the DecoderThread may omit invoking Cond::signal(), - * reducing the number of system calls. - */ - bool client_is_waiting = false; - bool seek_error; bool seekable; SongTime seek_time;