不确定我是否遗漏了什么,但我怎么能通过 boost::posix_time::ptime
反对 boost::this_thread::sleep_until()
?更具体地说:我如何从 boost::posix_time::ptime
转换至 boost::chrono::time_point
?
void do_magic( const boost::posix_time::ptime& wakeup_time )
{
boost::this_thread::sleep_until( wakeup_time ); // not working
do_more_magic();
}
我正在使用 boost 版
1.62
,如果这有任何相关性。
最佳答案
同时,此问题已通过 deadline_timer
解决。 . boost::asio
有解决方法:
// Construct a timer without setting an expiry time.
boost::asio::deadline_timer timer(my_context);
// Set an expiry time relative to now.
timer.expires_from_now(boost::posix_time::seconds(5));
// Wait for the timer to expire.
timer.wait();
关于c++ - boost:如何使当前线程休眠直到给定 ptime?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59280774/