From 44c2f733dcf535044e602740ac7d8a6b6ef90e7e Mon Sep 17 00:00:00 2001 From: eidheim Date: Mon, 20 May 2019 18:39:54 +0200 Subject: [PATCH] New asio api: removed unnecessary SimpleWeb::timer_expires_after --- asio_compatibility.hpp | 8 +------- client_http.hpp | 7 +------ server_http.hpp | 7 +------ 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/asio_compatibility.hpp b/asio_compatibility.hpp index 6e932fd..759c595 100644 --- a/asio_compatibility.hpp +++ b/asio_compatibility.hpp @@ -25,7 +25,7 @@ namespace SimpleWeb { #endif namespace SimpleWeb { -#if(USE_STANDALONE_ASIO && ASIO_VERSION >= 101300) || BOOST_ASIO_VERSION >= 101300 // TODO: change to 101300 +#if(USE_STANDALONE_ASIO && ASIO_VERSION >= 101300) || BOOST_ASIO_VERSION >= 101300 using io_context = asio::io_context; using resolver_results = asio::ip::tcp::resolver::results_type; using async_connect_endpoint = asio::ip::tcp::endpoint; @@ -33,9 +33,6 @@ namespace SimpleWeb { inline void restart(io_context &context) noexcept { context.restart(); } - inline void timer_expires_after(asio::steady_timer &timer, const asio::steady_timer::duration &duration) { - timer.expires_after(duration); - } inline asio::ip::address make_address(const std::string &str) noexcept { return asio::ip::make_address(str); } @@ -63,9 +60,6 @@ namespace SimpleWeb { inline void restart(io_context &context) noexcept { context.reset(); } - inline void timer_expires_after(asio::steady_timer &timer, const asio::steady_timer::duration &duration) { - timer.expires_from_now(duration); - } inline asio::ip::address make_address(const std::string &str) noexcept { return asio::ip::address::from_string(str); } diff --git a/client_http.hpp b/client_http.hpp index 532993c..bb2205a 100644 --- a/client_http.hpp +++ b/client_http.hpp @@ -99,12 +99,7 @@ namespace SimpleWeb { timer = nullptr; return; } - timer = std::unique_ptr(new asio::steady_timer(get_socket_context(*socket))); - try { - timer_expires_after(*timer, std::chrono::seconds(seconds)); - } - catch(...) { - } + timer = std::unique_ptr(new asio::steady_timer(get_socket_context(*socket), std::chrono::seconds(seconds))); auto self = this->shared_from_this(); timer->async_wait([self](const error_code &ec) { if(!ec) { diff --git a/server_http.hpp b/server_http.hpp index c092874..01d4835 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -278,12 +278,7 @@ namespace SimpleWeb { return; } - timer = std::unique_ptr(new asio::steady_timer(get_socket_context(*socket))); - try { - timer_expires_after(*timer, std::chrono::seconds(seconds)); - } - catch(...) { - } + timer = std::unique_ptr(new asio::steady_timer(get_socket_context(*socket), std::chrono::seconds(seconds))); auto self = this->shared_from_this(); timer->async_wait([self](const error_code &ec) { if(!ec)