Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This could occur if there were multiple consumers waiting on an empty queue, at least one of which is trying to call `pop_one`, and the producer adds a single element. If, after that operation, the producer adds at least one more element before the one awakened consumer can call `pop_one`, then the producer will not alert any other consumers that there is more data in the queue and they will not have a chance to be reawakened until the queue is empty again or their thread is cancelled. There are two possible fixes to this issue. The first option is to always notify all consumers if the queue was empty and it's possible one of the consumers is asking for a single element, rather than the current behavior of the notification count depending on whether we are adding one or several. The second option is to unconditionally notify one consumer, regardless of whether the queue was empty. This commit goes with option 1: it means we call `notify_all` when a `notify_one` would have sufficed in some cases, but it means that multiple consecutive calls to add data do not notify anyone. This seems like the right trade-off, but some use cases may prefer the other option.
- Loading branch information