From 4cbdda09e3589d4a39710b57a6c0bffbbe6ce16e Mon Sep 17 00:00:00 2001 From: Drew Lewis Date: Wed, 1 Oct 2025 02:39:38 +0000 Subject: [PATCH] Change DispatchQueue::dispatch to use notify_one. This prevents the thundering herd problem and should increase the scalability of the DispatchQueue significantly. Additionally the code the DispatchQueue was taken from made this improvement five years ago: https://github.com/embeddedartistry/embedded-resources/commit/79ad8a539d7e264350464e434e03b5d910ae4a29 Signed-off-by: Drew Lewis --- util/DispatchQueue.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/DispatchQueue.cc b/util/DispatchQueue.cc index e8a31e5f..c5f85e62 100644 --- a/util/DispatchQueue.cc +++ b/util/DispatchQueue.cc @@ -66,7 +66,7 @@ DispatchQueue::dispatch(const fp_t& op) // Manual unlocking is done before notifying, to avoid waking up // the waiting thread only to block again (see notify_one for details) lock.unlock(); - cv_.notify_all(); + cv_.notify_one(); } void @@ -79,7 +79,7 @@ DispatchQueue::dispatch(fp_t&& op) // Manual unlocking is done before notifying, to avoid waking up // the waiting thread only to block again (see notify_one for details) lock.unlock(); - cv_.notify_all(); + cv_.notify_one(); } void