From c147e9a90e92ceec17d778d3c6e5cf6f028109b3 Mon Sep 17 00:00:00 2001 From: FernandoS27 Date: Tue, 6 Apr 2021 06:02:44 +0200 Subject: common/thread_worker: Simplify logic --- src/common/thread_worker.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/common/thread_worker.cpp b/src/common/thread_worker.cpp index fd130dfb4..32be49b15 100644 --- a/src/common/thread_worker.cpp +++ b/src/common/thread_worker.cpp @@ -12,13 +12,6 @@ ThreadWorker::ThreadWorker(std::size_t num_workers, const std::string& name) { const auto lambda = [this, thread_name{std::string{name}}] { Common::SetCurrentThreadName(thread_name.c_str()); - // TODO(Blinkhawk): Change the design, this is very prone to data races - // Wait for first request - { - std::unique_lock lock{queue_mutex}; - condition.wait(lock, [this] { return stop || !requests.empty(); }); - } - while (!stop) { UniqueFunction task; { @@ -27,7 +20,7 @@ ThreadWorker::ThreadWorker(std::size_t num_workers, const std::string& name) { wait_condition.notify_all(); } condition.wait(lock, [this] { return stop || !requests.empty(); }); - if (stop || requests.empty()) { + if (stop) { break; } task = std::move(requests.front()); -- cgit v1.2.3