【发布时间】:2013-04-16 17:36:34
【问题描述】:
最初我使用的是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> &'
【问题讨论】:
-
只是一点:你永远不知道并发算法是有效的。除非你在数学上证明它。这无法完成,因为编译器和硬件无法证明。
标签: boost locking boost-thread