Boost ASIO steady_timer and date change
Hello, I'm using a steady_timer to perform an asynchronous wait in the following manner: boost::asio::io_service io_service; boost::asio::steady_timer my_timer(io_service); void onTimeout(const boost::system::error_code& e) { // Print something } ... my_timer.expires_from_now(std::chrono::seconds(600)); my_timer.async_wait(onTimeout); io_service.run(); If system 'date' does not change, everything is ok. But if I change 'date' by hand while the timer is running, it expires before 600 seconds (more or less after 5 minutes) and 'onTimeout' is called. With synchronous wait, all is ok. According to documentation, steady_timer should not be affected by time change. Which may be the problem? Thanks, Sabino
From: Sabino Colonna
To: boost-users@lists.boost.org Date: 05/06/2016 12:50 PM Subject: [Boost-users] Boost ASIO steady_timer and date change Sent by: "Boost-users" Hello,
I'm using a steady_timer to perform an asynchronous wait in the following manner:
boost::asio::io_service io_service; boost::asio::steady_timer my_timer(io_service);
void onTimeout(const boost::system::error_code& e) { // Print something }
... my_timer.expires_from_now(std::chrono::seconds(600)); my_timer.async_wait(onTimeout); io_service.run();
If system 'date' does not change, everything is ok. But if I change 'date' by hand while the timer is running, it expires before 600 seconds (more or less after 5 minutes) and 'onTimeout' is called. With synchronous wait, all is ok. According to documentation, steady_timer should not be affected by time change. Which may be the problem?
I had some weird issues with the steady timer a while back. I did a little digging and found that the steady timer can silently be replaced by the normal system timer in the standard library. I used BOOST_ASIO_DISABLE_STD_CHRONO to disable this "functionality". I have no clue what the standard library was thinking.
Hi Aaron, Thanks for your reply. I followed your suggestion and now it seems the steady timer behaves normally even if I change 'date' while is running. Thanks and regards, Sabino -- View this message in context: http://boost.2283326.n4.nabble.com/Boost-ASIO-steady-timer-and-date-change-t... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (2)
-
Aaron_Wright@selinc.com
-
Sabino Colonna