From a7b227bdbed7ec2e74565772d63e61ae11106d56 Mon Sep 17 00:00:00 2001 From: eidheim Date: Wed, 26 Aug 2020 11:45:30 +0200 Subject: Fixed compilation issues for older (boost.)asio versions --- asio_compatibility.hpp | 10 +++++----- client_ws.hpp | 2 +- server_ws.hpp | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/asio_compatibility.hpp b/asio_compatibility.hpp index 3d2df07..c2e0b66 100644 --- a/asio_compatibility.hpp +++ b/asio_compatibility.hpp @@ -43,8 +43,8 @@ namespace SimpleWeb { return asio::ip::make_address(str); } template - asio::steady_timer make_steady_timer(socket_type &socket, std::chrono::duration duration) { - return asio::steady_timer(socket.get_executor(), duration); + std::unique_ptr make_steady_timer(socket_type &socket, std::chrono::duration duration) { + return std::unique_ptr(new asio::steady_timer(socket.get_executor(), duration)); } template void async_resolve(asio::ip::tcp::resolver &resolver, const std::pair &host_port, handler_type &&handler) { @@ -68,9 +68,9 @@ namespace SimpleWeb { inline asio::ip::address make_address(const std::string &str) noexcept { return asio::ip::address::from_string(str); } - template - io_context &get_socket_executor(socket_type &socket) { - return socket.get_io_service(); + template + std::unique_ptr make_steady_timer(socket_type &socket, std::chrono::duration duration) { + return std::unique_ptr(new asio::steady_timer(socket.get_io_service(), duration)); } template void async_resolve(asio::ip::tcp::resolver &resolver, const std::pair &host_port, handler_type &&handler) { diff --git a/client_ws.hpp b/client_ws.hpp index 3448c3a..72d8d9e 100644 --- a/client_ws.hpp +++ b/client_ws.hpp @@ -106,7 +106,7 @@ namespace SimpleWeb { return; } - timer = std::unique_ptr(new asio::steady_timer(make_steady_timer(*socket, std::chrono::seconds(seconds)))); + timer = make_steady_timer(*socket, std::chrono::seconds(seconds)); std::weak_ptr connection_weak(this->shared_from_this()); // To avoid keeping Connection instance alive longer than needed timer->async_wait([connection_weak, use_timeout_idle](const error_code &ec) { if(!ec) { diff --git a/server_ws.hpp b/server_ws.hpp index 90379ae..071a492 100644 --- a/server_ws.hpp +++ b/server_ws.hpp @@ -160,7 +160,7 @@ namespace SimpleWeb { return; } - timer = std::unique_ptr(new asio::steady_timer(make_steady_timer(*socket, std::chrono::seconds(seconds)))); + timer = make_steady_timer(*socket, std::chrono::seconds(seconds)); std::weak_ptr connection_weak(this->shared_from_this()); // To avoid keeping Connection instance alive longer than needed timer->async_wait([connection_weak](const error_code &ec) { if(!ec) { -- cgit v1.2.3