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 <[email protected]>
This commit is contained in:
Drew Lewis
2025-10-12 14:11:21 -07:00
committed by GitHub
parent 36e516924f
commit daeea4ab7e
+2 -2
View File
@@ -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