]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/asio/example/cpp03/chat/chat_client.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / asio / example / cpp03 / chat / chat_client.cpp
index 68ea577b36b15200047fdf11c2e2a40733c5abbc..e37dfe4b574a9400123463e58b919235f981fc43 100644 (file)
@@ -2,7 +2,7 @@
 // chat_client.cpp
 // ~~~~~~~~~~~~~~~
 //
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2017 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)
@@ -23,24 +23,26 @@ typedef std::deque<chat_message> chat_message_queue;
 class chat_client
 {
 public:
-  chat_client(boost::asio::io_service& io_service,
-      tcp::resolver::iterator endpoint_iterator)
-    : io_service_(io_service),
-      socket_(io_service)
+  chat_client(boost::asio::io_context& io_context,
+      const tcp::resolver::results_type& endpoints)
+    : io_context_(io_context),
+      socket_(io_context)
   {
-    boost::asio::async_connect(socket_, endpoint_iterator,
+    boost::asio::async_connect(socket_, endpoints,
         boost::bind(&chat_client::handle_connect, this,
           boost::asio::placeholders::error));
   }
 
   void write(const chat_message& msg)
   {
-    io_service_.post(boost::bind(&chat_client::do_write, this, msg));
+    boost::asio::post(io_context_,
+        boost::bind(&chat_client::do_write, this, msg));
   }
 
   void close()
   {
-    io_service_.post(boost::bind(&chat_client::do_close, this));
+    boost::asio::post(io_context_,
+        boost::bind(&chat_client::do_close, this));
   }
 
 private:
@@ -128,7 +130,7 @@ private:
   }
 
 private:
-  boost::asio::io_service& io_service_;
+  boost::asio::io_context& io_context_;
   tcp::socket socket_;
   chat_message read_msg_;
   chat_message_queue write_msgs_;
@@ -144,15 +146,14 @@ int main(int argc, char* argv[])
       return 1;
     }
 
-    boost::asio::io_service io_service;
+    boost::asio::io_context io_context;
 
-    tcp::resolver resolver(io_service);
-    tcp::resolver::query query(argv[1], argv[2]);
-    tcp::resolver::iterator iterator = resolver.resolve(query);
+    tcp::resolver resolver(io_context);
+    tcp::resolver::results_type endpoints = resolver.resolve(argv[1], argv[2]);
 
-    chat_client c(io_service, iterator);
+    chat_client c(io_context, endpoints);
 
-    boost::thread t(boost::bind(&boost::asio::io_service::run, &io_service));
+    boost::thread t(boost::bind(&boost::asio::io_context::run, &io_context));
 
     char line[chat_message::max_body_length + 1];
     while (std::cin.getline(line, chat_message::max_body_length + 1))