23 Oct
2008
23 Oct
'08
3:42 p.m.
boost::asio::deadline_timer timer(io, boost::posix_time::seconds(5)); boost::thread thread(boost::bind(&boost::asio::io_service::run, &io)); timer.async_wait(on_time_out); delay(3);
Note that you set the timer timeout to be 5 second, but wait 3 second only.
cout << second_clock::local_time() << " Restarting timer" << endl; timer.expires_from_now(boost::posix_time::seconds(5));
You just change the timeout here. To restart the timer you have to call timer.async_wait(). By the way, note that the timer is not threadsafe so I'm not sure it's legal to restart it here or to change its timeout this way.