views:

28

answers:

1

Hello to all, i encounter an error in the code below.

recursive_mutex m_RecurMutex;
condition_variable cond;
unique_lock<recursive_mutex> lock(m_RecurMutex);
cond.wait(lock); // Error Here. 

What is the reason cause this error ?

Thanks.

A: 

I assume the error is

mutex.cc: In function ‘int main()’:
mutex.cc:9: error: no matching function for call to ‘boost::condition_variable::wait(boost::unique_lock<boost::recursive_mutex>&)’
/opt/local/include/boost/thread/pthread/condition_variable.hpp:17: note: candidates are: void boost::condition_variable::wait(boost::unique_lock<boost::mutex>&)
i

if not, please correct me. The documentation shows boost::condition_variable::lock takes a boost::unique_lock<boost::mutex> as an argument, not a boost::unique_lock<boost::recursive_mutex> as in your example.

Sam Miller
I thought the boost::recursive_mutex is a specialization of boost::mutex.
peterwkc
@peterwkc where in the documentation does it say that?
Sam Miller
I just assume this is the case. Sorry.
peterwkc
@peterwkc, no reason to be sorry. We are here to help, good luck!
Sam Miller