Use steady_timer rather than deadline_timer in wesnothd.

wesnothd has four timers, three were using steady_timer, one was using deadline timer. This changes the final timer to be a steady_timer, which won't be affected by clock changes whereas deadline_timer would be affected. It also allows using std::chrono instead of boost::posix_time.
This commit is contained in:
Pentarctagon 2020-10-15 23:42:42 -05:00 committed by Pentarctagon
parent 62afd8bef7
commit d757ee280b
2 changed files with 4 additions and 4 deletions

View file

@ -301,7 +301,7 @@ void server::handle_graceful_timeout(const boost::system::error_code& error)
process_command("msg All games ended. Shutting down now. Reconnect to the new server instance.", "system");
throw server_shutdown("graceful shutdown timeout");
} else {
timer_.expires_from_now(boost::posix_time::seconds(1));
timer_.expires_from_now(std::chrono::seconds(1));
timer_.async_wait(std::bind(&server::handle_graceful_timeout, this, _1));
}
}
@ -2043,7 +2043,7 @@ void server::shut_down_handler(
acceptor_v6_.close();
acceptor_v4_.close();
timer_.expires_from_now(boost::posix_time::seconds(10));
timer_.expires_from_now(std::chrono::seconds(10));
timer_.async_wait(std::bind(&server::handle_graceful_timeout, this, _1));
process_command(
@ -2074,7 +2074,7 @@ void server::restart_handler(const std::string& issuer_name,
graceful_restart = true;
acceptor_v6_.close();
acceptor_v4_.close();
timer_.expires_from_now(boost::posix_time::seconds(10));
timer_.expires_from_now(std::chrono::seconds(10));
timer_.async_wait(std::bind(&server::handle_graceful_timeout, this, _1));
start_new_server();

View file

@ -233,7 +233,7 @@ private:
void handle_sighup(const boost::system::error_code& error, int signal_number);
#endif
boost::asio::deadline_timer timer_;
boost::asio::steady_timer timer_;
void handle_graceful_timeout(const boost::system::error_code& error);
boost::asio::steady_timer lan_server_timer_;