0
votes

Could somebody clarify the meaning of the bold part on this remark? If possible with a code snippet.

I can't identify what's referred as calling thread and functions in this context.

Is there any difference with the behaviour of condition_variable on linux (gcc + pthreads) ?

Remarks

Code that waits for a condition variable must also use a mutex. A calling thread must lock the mutex before it calls the functions that wait for the condition variable. The mutex is then locked when the called function returns. The mutex is not locked while the thread waits for the condition to become true. So that there are no unpredictable results, each thread that waits for a condition variable must use the same mutex object.1

I've a bug that shows up only on Windows. notify_one() seems to be ignored but the code works OK if using wait_for() instead of wait() (still trying to produce an MCVE for that).

1
possible duplicate of my question : stackoverflow.com/questions/42470773/… - David Haim

1 Answers

0
votes

calling thread is the thread that makes the call to one of std::condition_variable::wait overloaded functions.