Amanieu / parking_lot

Compact and efficient synchronization primitives for Rust. Also provides an API for creating custom synchronization primitives.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Why does `notify_one_slow` return true even if threads were only requeued, and not unparked?

bzm3r opened this issue · comments

This is a conceptual question.

In notify_one_slow on Condvar, we have:

res.unparked_threads + res.requeued_threads != 0

Suppose res.unparked_threads == 0, but res.requeued_threads > 0, then should notify_one_slow return true?

notify_one returns true if a thread was waiting on the condvar and has now been woken up. It doesn't matter whether this was done by waking it up directly or requeuing it to the mutex so that it will be woken up when the mutex is unlocked.

@Amanieu Thank you, that makes sense!