Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++11 threads: notify_all() or notify_one() when I only have one?

My threads operate as a linked list(with overlap, hence threads), implementing something not dissimilar to a timeline. Each condition variable unlocks the next thread in the linked list.

Should I use notify_all() or notify_one() when I have only one to notify?

like image 718
Mikhail Avatar asked Dec 15 '25 20:12

Mikhail


1 Answers

Use notify_one unless your code makes it easier to read notify_all (for example you've constructed a list which just happens to have one element in it).

like image 144
SecurityMatt Avatar answered Dec 17 '25 08:12

SecurityMatt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!