]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/asio/example/cpp11/spawn/echo_server.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / asio / example / cpp11 / spawn / echo_server.cpp
index 979c9a9273dbbb28e14958cb5f0861d4e1c67b29..b32d827aaa1f7e7829dc3d65d11d30ebe07fc792 100644 (file)
@@ -2,7 +2,7 @@
 // echo_server.cpp
 // ~~~~~~~~~~~~~~~
 //
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2019 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)
@@ -21,10 +21,10 @@ using boost::asio::ip::tcp;
 class session : public std::enable_shared_from_this<session>
 {
 public:
-  explicit session(tcp::socket socket)
+  explicit session(boost::asio::io_context& io_context, tcp::socket socket)
     : socket_(std::move(socket)),
-      timer_(socket_.get_io_context()),
-      strand_(socket_.get_io_context())
+      timer_(io_context),
+      strand_(io_context.get_executor())
   {
   }
 
@@ -67,7 +67,7 @@ public:
 private:
   tcp::socket socket_;
   boost::asio::steady_timer timer_;
-  boost::asio::io_context::strand strand_;
+  boost::asio::strand<boost::asio::io_context::executor_type> strand_;
 };
 
 int main(int argc, char* argv[])
@@ -93,7 +93,10 @@ int main(int argc, char* argv[])
             boost::system::error_code ec;
             tcp::socket socket(io_context);
             acceptor.async_accept(socket, yield[ec]);
-            if (!ec) std::make_shared<session>(std::move(socket))->go();
+            if (!ec)
+            {
+              std::make_shared<session>(io_context, std::move(socket))->go();
+            }
           }
         });