in reply to Re^9: need a thread to wait until a buffer is full.
in thread need a thread to wait until a buffer is full.
but if the thread waits (without any timeslices) for the cond_signal from the other thread, that would limit it to watching only 1 thread.
No, that is not so. The variable upon which the cond_wait() is waiting can be cond_signal()ed from any thread (that has a lock on the variable).
Also, if more than one thread are in a cond_wait() state on the same variable, one of them (non-determanistically) will be awoken.
You can also signal a variable using cond_broadcast(), in which case all threads currently blocking on that variable will be woken up, rather than just one.
|
|---|