C ++ state variable and waiting
1 answer
He will wait until he receives the message cv
that count < 6
. From reference :
Equivalent to
while (!pred()) { wait(lock); }
This overload can be used to ignore false wakes while waiting for a certain condition to become true. Please note that before entering this method, you need to acquire the lock, after it
wait(lock)
exits, it will also be restored, i.e. Blocking can be used as access protectionpred()
.
You can think of a predicate as a completion state to stop waiting.
0
source to share