diff options
author | 2021-11-15 04:15:13 +1100 | |
---|---|---|
committer | 2021-11-15 04:15:13 +1100 | |
commit | 44ec6d2e0ee569202b75b73eea40972595866779 (patch) | |
tree | b286443c264704198789514e0594dc24b3ca9f96 /3rdparty/asio/src/examples/cpp03/spawn/echo_server.cpp | |
parent | 137f254b918f1f1ebee43dfbed86793b0dae73eb (diff) |
3rdparty: Updated ASIO to version 1.20.0.
The doc folder isn't included as it's pretty big.
This required include/asio/detail/win_iocp_socket_accept_op.hpp due to
mismatched order in the member declarations and initialiser list for the
win_iocp_socket_accept_op class. I reversed the declaration order so it
matches win_iocp_socket_move_accept_op.
Diffstat (limited to '3rdparty/asio/src/examples/cpp03/spawn/echo_server.cpp')
-rw-r--r-- | 3rdparty/asio/src/examples/cpp03/spawn/echo_server.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/3rdparty/asio/src/examples/cpp03/spawn/echo_server.cpp b/3rdparty/asio/src/examples/cpp03/spawn/echo_server.cpp index 415f6da8f33..4549b446245 100644 --- a/3rdparty/asio/src/examples/cpp03/spawn/echo_server.cpp +++ b/3rdparty/asio/src/examples/cpp03/spawn/echo_server.cpp @@ -2,18 +2,18 @@ // echo_server.cpp // ~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2021 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // -#include <asio/deadline_timer.hpp> #include <asio/io_context.hpp> #include <asio/ip/tcp.hpp> #include <asio/spawn.hpp> +#include <asio/steady_timer.hpp> #include <asio/write.hpp> -#include <boost/bind.hpp> +#include <boost/bind/bind.hpp> #include <boost/shared_ptr.hpp> #include <boost/enable_shared_from_this.hpp> #include <iostream> @@ -24,7 +24,7 @@ class session : public boost::enable_shared_from_this<session> { public: explicit session(asio::io_context& io_context) - : strand_(io_context), + : strand_(asio::make_strand(io_context)), socket_(io_context), timer_(io_context) { @@ -39,10 +39,10 @@ public: { asio::spawn(strand_, boost::bind(&session::echo, - shared_from_this(), _1)); + shared_from_this(), boost::placeholders::_1)); asio::spawn(strand_, boost::bind(&session::timeout, - shared_from_this(), _1)); + shared_from_this(), boost::placeholders::_1)); } private: @@ -53,7 +53,7 @@ private: char data[128]; for (;;) { - timer_.expires_from_now(boost::posix_time::seconds(10)); + timer_.expires_after(asio::chrono::seconds(10)); std::size_t n = socket_.async_read_some(asio::buffer(data), yield); asio::async_write(socket_, asio::buffer(data, n), yield); } @@ -71,14 +71,14 @@ private: { asio::error_code ignored_ec; timer_.async_wait(yield[ignored_ec]); - if (timer_.expires_from_now() <= boost::posix_time::seconds(0)) + if (timer_.expiry() <= asio::steady_timer::clock_type::now()) socket_.close(); } } - asio::io_context::strand strand_; + asio::strand<asio::io_context::executor_type> strand_; tcp::socket socket_; - asio::deadline_timer timer_; + asio::steady_timer timer_; }; void do_accept(asio::io_context& io_context, @@ -109,7 +109,7 @@ int main(int argc, char* argv[]) asio::spawn(io_context, boost::bind(do_accept, - boost::ref(io_context), atoi(argv[1]), _1)); + boost::ref(io_context), atoi(argv[1]), boost::placeholders::_1)); io_context.run(); } |