
28 Mar
2011
28 Mar
'11
5:26 p.m.
On Mar 28, 2011, at 6:34 PM, Panagiotis Foteinos wrote:
Thank you for the reply.
To clarify things in my mind: Should I pass the lock itself to cond.wait for safety/correctness, or because this way I will get the desired behavior?
To have cond.wait call unlock_shared() / lock_shared(), cond should be of type condition_variable_any, and you should pass in shared_lock<shared_mutex> with owns_lock() == true. If you pass a shared_mutex directly to condition_variable_any::wait(), it will call unlock() on the mutex, which will be a run time error if the mutex has been lock_shared(). If you pass a shared_mutex or shared_lock to a condition_variable::wait() (as opposed to condition_variable_any), you will get a compile time error. -Howard