我想知道我做错了什么......wait
它编译和运行的鞋底,但不是timed_wait
:
using boost::interprocess::scoped_lock;
using boost::interprocess::interprocess_mutex;
using boost::posix_time::milliseconds;
[...]
scoped_lock<interprocess_mutex> lock(obj->mutex);
while (...) {
obj->condition.timed_wait(lock, milliseconds(100));
}
哪里obj->mutex
是 aboost::interprocess::interprocess_mutex
并且obj->condition
是 a boost::interprocess::interprocess_condition
。这是 g++ 错误日志:
code.cpp: In member function ‘[...]’:
code.cpp:42: error: no matching function for call to ‘boost::interprocess::interprocess_condition::timed_wait(boost::interprocess::scoped_lock<boost::interprocess::interprocess_mutex>&, boost::posix_time::milliseconds)
而这是条件类成员函数的原型(boost/interprocess/sync/interprocess_condition.hpp):
template <typename L, typename Pr>
bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
(提升 1.40)