【发布时间】:2011-01-13 10:02:04
【问题描述】:
以下代码重现了错误:
#include <iostream>
#include "boost/thread.hpp"
#include "boost/date_time/posix_time/ptime.hpp"
int main()
{
boost::condition_variable_any cv;
boost::timed_mutex m;
try {
{
boost::timed_mutex::scoped_timed_lock guard(m);
cv.timed_wait(guard, boost::posix_time::ptime(
boost::posix_time::pos_infin));
}
}
catch(std::exception & e) {
std::cout << "Error : " << e.what() << std::endl;
}
std::cout << "Done" << std::endl;
return 0;
}
在我的系统上,使用 Visual Studio 2005 和 Boost 1.43,这会产生以下输出:
Error : Year is out of valid range: 1400..10000
Done
我希望它会死锁,等待条件变量永远得到通知。这似乎没有在任何地方记录,而且我希望timed_wait 接受任何有效的ptime。我做错什么了吗?这是一个错误,还是无意无限超时?
【问题讨论】:
-
无法在 1.45.0 的 linux 上重现。如果在 1.45.0 中修复,您可以试试吗?
-
我会先安装它,所以需要一点时间。
-
@chris:我查了一下,1.45也出现了错误。
-
@Space_C0wb0y 它不会为我在 Mac OS X 上使用 boost 1.45 进行复制。不过,对于复制器 +1。
-
用 Visual Studio 2010 和 boost 1.46.1 复制
标签: c++ boost boost-thread condition-variable boost-date-time