Reputation: 11651
Initially I was using boost::mutex::scoped_lock
as such (which worked)
boost::mutex::scoped_lock lock(mutex_name);
condition.wait(lock); //where condition = boost::condition_variable
However later I changed the lock to the following which does not work
boost::lock_guard<boost::mutex> lock(mutex_name)
condition.wait(lock); //Error
Any suggestions on how to resolve the issue I get intellisense error stating No instance of the overloaded function matches the argument list
. The compile error is
Error 7 error C2664: 'void boost::condition_variable::wait(boost::unique_lock<Mutex> &)' : cannot convert parameter 1 from 'boost::lock_guard<Mutex>' to 'boost::unique_lock<Mutex> &'
Upvotes: 0
Views: 1401
Reputation: 15075
boost::lock_guard
doesn't have unlock
member-function, which is needed for condition
. Use unique_lock
instead:
boost::unique_lock<boost::mutex> lock(mut);
condition.wait(lock);
Upvotes: 3