Fixes another compilation issue: make_steady_timer now returns std::unique_ptr

This commit is contained in:
eidheim 2020-08-26 11:43:28 +02:00
commit 5d65a5d89b
3 changed files with 6 additions and 6 deletions

View file

@ -43,8 +43,8 @@ namespace SimpleWeb {
return asio::ip::make_address(str); return asio::ip::make_address(str);
} }
template <typename socket_type, typename duration_type> template <typename socket_type, typename duration_type>
asio::steady_timer make_steady_timer(socket_type &socket, std::chrono::duration<duration_type> duration) { std::unique_ptr<asio::steady_timer> make_steady_timer(socket_type &socket, std::chrono::duration<duration_type> duration) {
return asio::steady_timer(socket.get_executor(), duration); return std::unique_ptr<asio::steady_timer>(new asio::steady_timer(socket.get_executor(), duration));
} }
template <typename handler_type> template <typename handler_type>
void async_resolve(asio::ip::tcp::resolver &resolver, const std::pair<std::string, std::string> &host_port, handler_type &&handler) { void async_resolve(asio::ip::tcp::resolver &resolver, const std::pair<std::string, std::string> &host_port, handler_type &&handler) {
@ -69,8 +69,8 @@ namespace SimpleWeb {
return asio::ip::address::from_string(str); return asio::ip::address::from_string(str);
} }
template <typename socket_type, typename duration_type> template <typename socket_type, typename duration_type>
asio::steady_timer make_steady_timer(socket_type &socket, std::chrono::duration<duration_type> duration) { std::unique_ptr<asio::steady_timer> make_steady_timer(socket_type &socket, std::chrono::duration<duration_type> duration) {
return asio::steady_timer(socket.get_io_service(), duration); return std::unique_ptr<asio::steady_timer>(new asio::steady_timer(socket.get_io_service(), duration));
} }
template <typename handler_type> template <typename handler_type>
void async_resolve(asio::ip::tcp::resolver &resolver, const std::pair<std::string, std::string> &host_port, handler_type &&handler) { void async_resolve(asio::ip::tcp::resolver &resolver, const std::pair<std::string, std::string> &host_port, handler_type &&handler) {

View file

@ -173,7 +173,7 @@ namespace SimpleWeb {
timer = nullptr; timer = nullptr;
return; return;
} }
timer = std::unique_ptr<asio::steady_timer>(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> self_weak(this->shared_from_this()); // To avoid keeping Connection instance alive longer than needed std::weak_ptr<Connection> self_weak(this->shared_from_this()); // To avoid keeping Connection instance alive longer than needed
timer->async_wait([self_weak](const error_code &ec) { timer->async_wait([self_weak](const error_code &ec) {
if(!ec) { if(!ec) {

View file

@ -303,7 +303,7 @@ namespace SimpleWeb {
return; return;
} }
timer = std::unique_ptr<asio::steady_timer>(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> self_weak(this->shared_from_this()); // To avoid keeping Connection instance alive longer than needed std::weak_ptr<Connection> self_weak(this->shared_from_this()); // To avoid keeping Connection instance alive longer than needed
timer->async_wait([self_weak](const error_code &ec) { timer->async_wait([self_weak](const error_code &ec) {
if(!ec) { if(!ec) {