]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/asio/example/cpp03/http/server3/server.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / asio / example / cpp03 / http / server3 / server.cpp
index 99cd9ebf6be472b3896d0758ff246d44ec98d6e1..fc1c651686c290f5bd5c227bfff6cb6cece2923f 100644 (file)
@@ -2,7 +2,7 @@
 // server.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)
@@ -20,8 +20,8 @@ namespace server3 {
 server::server(const std::string& address, const std::string& port,
     const std::string& doc_root, std::size_t thread_pool_size)
   : thread_pool_size_(thread_pool_size),
-    signals_(io_service_),
-    acceptor_(io_service_),
+    signals_(io_context_),
+    acceptor_(io_context_),
     new_connection_(),
     request_handler_(doc_root)
 {
@@ -36,9 +36,9 @@ server::server(const std::string& address, const std::string& port,
   signals_.async_wait(boost::bind(&server::handle_stop, this));
 
   // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR).
-  boost::asio::ip::tcp::resolver resolver(io_service_);
-  boost::asio::ip::tcp::resolver::query query(address, port);
-  boost::asio::ip::tcp::endpoint endpoint = *resolver.resolve(query);
+  boost::asio::ip::tcp::resolver resolver(io_context_);
+  boost::asio::ip::tcp::endpoint endpoint =
+    *resolver.resolve(address, port).begin();
   acceptor_.open(endpoint.protocol());
   acceptor_.set_option(boost::asio::ip::tcp::acceptor::reuse_address(true));
   acceptor_.bind(endpoint);
@@ -49,12 +49,12 @@ server::server(const std::string& address, const std::string& port,
 
 void server::run()
 {
-  // Create a pool of threads to run all of the io_services.
+  // Create a pool of threads to run all of the io_contexts.
   std::vector<boost::shared_ptr<boost::thread> > threads;
   for (std::size_t i = 0; i < thread_pool_size_; ++i)
   {
     boost::shared_ptr<boost::thread> thread(new boost::thread(
-          boost::bind(&boost::asio::io_service::run, &io_service_)));
+          boost::bind(&boost::asio::io_context::run, &io_context_)));
     threads.push_back(thread);
   }
 
@@ -65,7 +65,7 @@ void server::run()
 
 void server::start_accept()
 {
-  new_connection_.reset(new connection(io_service_, request_handler_));
+  new_connection_.reset(new connection(io_context_, request_handler_));
   acceptor_.async_accept(new_connection_->socket(),
       boost::bind(&server::handle_accept, this,
         boost::asio::placeholders::error));
@@ -83,7 +83,7 @@ void server::handle_accept(const boost::system::error_code& e)
 
 void server::handle_stop()
 {
-  io_service_.stop();
+  io_context_.stop();
 }
 
 } // namespace server3