julia
553b0b9d - Allow specifying waitfirst when waiting on a Condition (#47277)

Commit
3 years ago
Allow specifying waitfirst when waiting on a Condition (#47277) * Allow specifying waitfirst when waiting on a Condition I have a use-case where I use a `Condition` as a wait queue, where a singler waiter is woken up on `notify`. Once a waiter is woken up, it may need to re-wait, but we want it to get back in the wait queue _first_ instead of the FIFO behavior of regular `wait`. This allows the waiter to continue being notified until a logical condition is met and the next waiter in the queue will take the next notification. This PR proposes adding a keyword argument `waitfirst::Bool=false` to the `wait(c::Condition)` method that allows the caller to put itself _first_ in the `Condition` wait queue instead of last. I didn't consider whether other `wait` methods (Channel, Task, etc.) would also benefit from something like this to minimize the total changes to a specific use-case that I know is useful. * change waitfirst -> first as suggested by jameson
Author
Parents
Loading