void wait(implementation_type& impl, boost::system::error_code& ec)
{
time_type now = Time_Traits::now();
while (Time_Traits::less_than(now, impl.expiry))
{
boost::posix_time::time_duration timeout =
Time_Traits::to_posix_duration(Time_Traits::subtract(impl.expiry, now));
::timeval tv;
tv.tv_sec = timeout.total_seconds();
tv.tv_usec = timeout.total_microseconds() % 1000000;
boost::system::error_code ec;
socket_ops::select(0, 0, 0, 0, &tv, ec);
now = Time_Traits::now();
}
ec = boost::system::error_code();
}
用 select 实现 定时器功能,摘抄自boost.asio
最新推荐文章于 2022-12-12 15:11:20 发布