0

最初我是boost::mutex::scoped_lock这样使用的(有效)

boost::mutex::scoped_lock lock(mutex_name); 
condition.wait(lock); //where condition = boost::condition_variable

但是后来我将锁更改为以下不起作用

boost::lock_guard<boost::mutex> lock(mutex_name)
condition.wait(lock); //Error

有关如何解决问题的任何建议,我都会收到智能感知错误说明No instance of the overloaded function matches the argument list。编译错误是

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> &'  
4

1 回答 1

3

boost::lock_guard没有unlock成员函数,这是condition. 改用unique_lock

boost::unique_lock<boost::mutex> lock(mut);
condition.wait(lock);
于 2013-04-16T17:57:02.040 回答