Skip to content

Commit daeea4a

Browse files
authored
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: embeddedartistry/embedded-resources@79ad8a5 Signed-off-by: Drew Lewis <[email protected]>
1 parent 36e5169 commit daeea4a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

util/DispatchQueue.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ DispatchQueue::dispatch(const fp_t& op)
6666
// Manual unlocking is done before notifying, to avoid waking up
6767
// the waiting thread only to block again (see notify_one for details)
6868
lock.unlock();
69-
cv_.notify_all();
69+
cv_.notify_one();
7070
}
7171

7272
void
@@ -79,7 +79,7 @@ DispatchQueue::dispatch(fp_t&& op)
7979
// Manual unlocking is done before notifying, to avoid waking up
8080
// the waiting thread only to block again (see notify_one for details)
8181
lock.unlock();
82-
cv_.notify_all();
82+
cv_.notify_one();
8383
}
8484

8585
void

0 commit comments

Comments
 (0)