From ac6bea58ffed37d1f2ee86af450417a8e68d6225 Mon Sep 17 00:00:00 2001 From: eidheim Date: Sun, 29 Dec 2019 10:55:57 +0100 Subject: [PATCH] Added SimpleWeb::post to asio_compability.hpp --- asio_compatibility.hpp | 8 ++++++++ server_http.hpp | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/asio_compatibility.hpp b/asio_compatibility.hpp index 2a29e5c..ca332c2 100644 --- a/asio_compatibility.hpp +++ b/asio_compatibility.hpp @@ -32,6 +32,10 @@ namespace SimpleWeb { using resolver_results = asio::ip::tcp::resolver::results_type; using async_connect_endpoint = asio::ip::tcp::endpoint; + template + inline void post(io_context &context, handler_type &&handler) { + asio::post(context, std::forward(handler)); + } inline void restart(io_context &context) noexcept { context.restart(); } @@ -51,6 +55,10 @@ namespace SimpleWeb { using resolver_results = asio::ip::tcp::resolver::iterator; using async_connect_endpoint = asio::ip::tcp::resolver::iterator; + template + inline void post(io_context &context, handler_type &&handler) { + context.post(std::forward(handler)); + } inline void restart(io_context &context) noexcept { context.reset(); } diff --git a/server_http.hpp b/server_http.hpp index 11470d9..1768cb8 100644 --- a/server_http.hpp +++ b/server_http.hpp @@ -442,7 +442,7 @@ namespace SimpleWeb { restart(*io_service); if(callback) - io_service->post(std::move(callback)); + post(*io_service, std::move(callback)); // If thread_pool_size>1, start m_io_service.run() in (thread_pool_size-1) threads for thread-pooling threads.clear(); @@ -461,7 +461,7 @@ namespace SimpleWeb { t.join(); } else if(callback) - io_service->post(std::move(callback)); + post(*io_service, std::move(callback)); } /// Start the server by calling bind() and accept_and_run().