From daeea4ab7e892aad762c8e50a9d19591d1d574d9 Mon Sep 17 00:00:00 2001 From: Drew Lewis Date: Sun, 12 Oct 2025 17:11:21 -0400 Subject: [PATCH] Change DispatchQueue::dispatch to use notify_one. (#308) 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