From eaa636edcbcc7a691b35ad2e7dc6d3755a928951 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 22 Oct 2024 15:00:54 +0200 Subject: [PATCH] Yield thread if task queues are empty --- src/mx/tasking/worker.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/mx/tasking/worker.cpp b/src/mx/tasking/worker.cpp index 3b4196d..aad1419 100644 --- a/src/mx/tasking/worker.cpp +++ b/src/mx/tasking/worker.cpp @@ -40,7 +40,7 @@ void Worker::execute() while (this->_is_running == false) { rt::Mutex mutex{}; - _stop.WaitTimed(&mutex, 10); + _stop.Wait(&mutex); _counter.fetch_add(1); //std::cout << "Worker " << _target_core_id << " woke up " << std::endl; } @@ -51,6 +51,9 @@ void Worker::execute() } this->_channel_size = this->_channel.fill(); + if (this->_channel.empty()) { + thread_yield(); + } if constexpr (config::task_statistics()) {