Add get_executor() to I/O objects.
diff --git a/asio/include/asio/basic_io_object.hpp b/asio/include/asio/basic_io_object.hpp
index 6154d92..0d9b2be 100644
--- a/asio/include/asio/basic_io_object.hpp
+++ b/asio/include/asio/basic_io_object.hpp
@@ -66,7 +66,9 @@
   /// The underlying implementation type of I/O object.
   typedef typename service_type::implementation_type implementation_type;
 
-  /// Get the io_service associated with the object.
+#if !defined(ASIO_NO_DEPRECATED)
+  /// (Deprecated: Use get_executor().) Get the io_service associated with the
+  /// object.
   /**
    * This function may be used to obtain the io_service object that the I/O
    * object uses to dispatch handlers for asynchronous operations.
@@ -78,6 +80,16 @@
   {
     return service.get_io_service();
   }
+#endif // !defined(ASIO_NO_DEPRECATED)
+
+  /// The type of the executor associated with the object.
+  typedef asio::io_service::executor_type executor_type;
+
+  /// Get the executor associated with the object.
+  executor_type get_executor() ASIO_NOEXCEPT
+  {
+    return service.get_io_service().get_executor();
+  }
 
 protected:
   /// Construct a basic_io_object.
@@ -172,10 +184,19 @@
   typedef IoObjectService service_type;
   typedef typename service_type::implementation_type implementation_type;
 
+#if !defined(ASIO_NO_DEPRECATED)
   asio::io_service& get_io_service()
   {
     return service_->get_io_service();
   }
+#endif // !defined(ASIO_NO_DEPRECATED)
+
+  typedef asio::io_service::executor_type executor_type;
+
+  executor_type get_executor() ASIO_NOEXCEPT
+  {
+    return service_->get_io_service().get_executor();
+  }
 
 protected:
   explicit basic_io_object(asio::io_service& io_service)
diff --git a/asio/include/asio/basic_socket.hpp b/asio/include/asio/basic_socket.hpp
index 0b9bc39..da223df 100644
--- a/asio/include/asio/basic_socket.hpp
+++ b/asio/include/asio/basic_socket.hpp
@@ -192,7 +192,7 @@
   template <typename Protocol1, typename SocketService1>
   basic_socket(basic_socket<Protocol1, SocketService1>&& other,
       typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
-    : basic_io_object<SocketService>(other.get_io_service())
+    : basic_io_object<SocketService>(other.get_service().get_io_service())
   {
     this->get_service().template converting_move_construct<Protocol1>(
         this->get_implementation(), other.get_implementation());
@@ -762,7 +762,7 @@
         async_completion<ConnectHandler,
           void (asio::error_code)> init(handler);
 
-        this->get_io_service().post(
+        this->get_service().get_io_service().post(
             asio::detail::bind_handler(
               ASIO_MOVE_CAST(ASIO_HANDLER_TYPE(
                 ConnectHandler, void (asio::error_code)))(
diff --git a/asio/include/asio/basic_socket_acceptor.hpp b/asio/include/asio/basic_socket_acceptor.hpp
index f69f483..a1c10ce 100644
--- a/asio/include/asio/basic_socket_acceptor.hpp
+++ b/asio/include/asio/basic_socket_acceptor.hpp
@@ -231,7 +231,8 @@
   basic_socket_acceptor(
       basic_socket_acceptor<Protocol1, SocketAcceptorService1>&& other,
       typename enable_if<is_convertible<Protocol1, Protocol>::value>::type* = 0)
-    : basic_io_object<SocketAcceptorService>(other.get_io_service())
+    : basic_io_object<SocketAcceptorService>(
+        other.get_service().get_io_service())
   {
     this->get_service().template converting_move_construct<Protocol1>(
         this->get_implementation(), other.get_implementation());
diff --git a/asio/include/asio/impl/connect.hpp b/asio/include/asio/impl/connect.hpp
index b0c7efc..4251f2b 100644
--- a/asio/include/asio/impl/connect.hpp
+++ b/asio/include/asio/impl/connect.hpp
@@ -25,6 +25,7 @@
 #include "asio/detail/handler_type_requirements.hpp"
 #include "asio/detail/throw_error.hpp"
 #include "asio/error.hpp"
+#include "asio/post.hpp"
 
 #include "asio/detail/push_options.hpp"
 
@@ -233,7 +234,8 @@
           if (start)
           {
             ec = asio::error::not_found;
-            socket_.get_io_service().post(detail::bind_handler(*this, ec));
+            asio::post(socket_.get_executor(),
+                detail::bind_handler(*this, ec));
             return;
           }
 
diff --git a/asio/include/asio/ssl/stream.hpp b/asio/include/asio/ssl/stream.hpp
index 373f226..e610f27 100644
--- a/asio/include/asio/ssl/stream.hpp
+++ b/asio/include/asio/ssl/stream.hpp
@@ -105,7 +105,8 @@
   template <typename Arg>
   stream(Arg& arg, context& ctx)
     : next_layer_(arg),
-      core_(ctx.native_handle(), next_layer_.lowest_layer().get_io_service())
+      core_(ctx.native_handle(),
+          next_layer_.lowest_layer().get_executor().context())
   {
     backwards_compatible_impl_.ssl = core_.engine_.native_handle();
   }
diff --git a/asio/src/examples/cpp03/http/server2/server.cpp b/asio/src/examples/cpp03/http/server2/server.cpp
index db726f2..6f739a8 100644
--- a/asio/src/examples/cpp03/http/server2/server.cpp
+++ b/asio/src/examples/cpp03/http/server2/server.cpp
@@ -33,7 +33,7 @@
   signals_.async_wait(boost::bind(&server::handle_stop, this));
 
   // Open the acceptor with the option to reuse the address (i.e. SO_REUSEADDR).
-  asio::ip::tcp::resolver resolver(acceptor_.get_io_service());
+  asio::ip::tcp::resolver resolver(acceptor_.get_executor().context());
   asio::ip::tcp::resolver::query query(address, port);
   asio::ip::tcp::endpoint endpoint = *resolver.resolve(query);
   acceptor_.open(endpoint.protocol());
diff --git a/asio/src/examples/cpp03/http/server4/server.cpp b/asio/src/examples/cpp03/http/server4/server.cpp
index ac29fd7..357259f 100644
--- a/asio/src/examples/cpp03/http/server4/server.cpp
+++ b/asio/src/examples/cpp03/http/server4/server.cpp
@@ -44,7 +44,7 @@
       do
       {
         // Create a new socket for the next incoming connection.
-        socket_.reset(new tcp::socket(acceptor_->get_io_service()));
+        socket_.reset(new tcp::socket(acceptor_->get_executor().context()));
 
         // Accept a new connection. The "yield" pseudo-keyword saves the current
         // line number and exits the coroutine's "reenter" block. We use the
diff --git a/asio/src/examples/cpp03/nonblocking/third_party_lib.cpp b/asio/src/examples/cpp03/nonblocking/third_party_lib.cpp
index 79b87fd..d2a61c0 100644
--- a/asio/src/examples/cpp03/nonblocking/third_party_lib.cpp
+++ b/asio/src/examples/cpp03/nonblocking/third_party_lib.cpp
@@ -195,7 +195,7 @@
   void start_accept()
   {
     connection::pointer new_connection =
-      connection::create(acceptor_.get_io_service());
+      connection::create(acceptor_.get_executor().context());
 
     acceptor_.async_accept(new_connection->socket(),
         boost::bind(&server::handle_accept, this, new_connection,
diff --git a/asio/src/examples/cpp03/porthopper/server.cpp b/asio/src/examples/cpp03/porthopper/server.cpp
index 012e577..7c6dc20 100644
--- a/asio/src/examples/cpp03/porthopper/server.cpp
+++ b/asio/src/examples/cpp03/porthopper/server.cpp
@@ -36,7 +36,8 @@
       next_frame_number_(1)
   {
     // Start waiting for a new control connection.
-    tcp_socket_ptr new_socket(new tcp::socket(acceptor_.get_io_service()));
+    tcp_socket_ptr new_socket(
+        new tcp::socket(acceptor_.get_executor().context()));
     acceptor_.async_accept(*new_socket,
         boost::bind(&server::handle_accept, this,
           asio::placeholders::error, new_socket));
@@ -59,7 +60,8 @@
     }
 
     // Start waiting for a new control connection.
-    tcp_socket_ptr new_socket(new tcp::socket(acceptor_.get_io_service()));
+    tcp_socket_ptr new_socket(
+        new tcp::socket(acceptor_.get_executor().context()));
     acceptor_.async_accept(*new_socket,
         boost::bind(&server::handle_accept, this,
           asio::placeholders::error, new_socket));
@@ -73,7 +75,7 @@
     {
       // Delay handling of the control request to simulate network latency.
       timer_ptr delay_timer(
-          new asio::deadline_timer(acceptor_.get_io_service()));
+          new asio::deadline_timer(acceptor_.get_executor().context()));
       delay_timer->expires_from_now(boost::posix_time::seconds(2));
       delay_timer->async_wait(
           boost::bind(&server::handle_control_request_timer, this,
diff --git a/asio/src/examples/cpp03/tutorial/daytime3/server.cpp b/asio/src/examples/cpp03/tutorial/daytime3/server.cpp
index c7feeee..8dde150 100644
--- a/asio/src/examples/cpp03/tutorial/daytime3/server.cpp
+++ b/asio/src/examples/cpp03/tutorial/daytime3/server.cpp
@@ -79,7 +79,7 @@
   void start_accept()
   {
     tcp_connection::pointer new_connection =
-      tcp_connection::create(acceptor_.get_io_service());
+      tcp_connection::create(acceptor_.get_executor().context());
 
     acceptor_.async_accept(new_connection->socket(),
         boost::bind(&tcp_server::handle_accept, this, new_connection,
diff --git a/asio/src/examples/cpp03/tutorial/daytime7/server.cpp b/asio/src/examples/cpp03/tutorial/daytime7/server.cpp
index 24ddacc..038a222 100644
--- a/asio/src/examples/cpp03/tutorial/daytime7/server.cpp
+++ b/asio/src/examples/cpp03/tutorial/daytime7/server.cpp
@@ -78,7 +78,7 @@
   void start_accept()
   {
     tcp_connection::pointer new_connection =
-      tcp_connection::create(acceptor_.get_io_service());
+      tcp_connection::create(acceptor_.get_executor().context());
 
     acceptor_.async_accept(new_connection->socket(),
         boost::bind(&tcp_server::handle_accept, this, new_connection,
diff --git a/asio/src/tests/unit/ip/tcp.cpp b/asio/src/tests/unit/ip/tcp.cpp
index 2e0ac72..d77a918 100644
--- a/asio/src/tests/unit/ip/tcp.cpp
+++ b/asio/src/tests/unit/ip/tcp.cpp
@@ -218,6 +218,9 @@
     io_service& ios_ref = socket1.get_io_service();
     (void)ios_ref;
 
+    ip::tcp::socket::executor_type ex = socket1.get_executor();
+    (void)ex;
+
     // basic_socket functions.
 
     ip::tcp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
diff --git a/asio/src/tests/unit/ip/udp.cpp b/asio/src/tests/unit/ip/udp.cpp
index fd28936..6a7c188 100644
--- a/asio/src/tests/unit/ip/udp.cpp
+++ b/asio/src/tests/unit/ip/udp.cpp
@@ -100,6 +100,9 @@
     io_service& ios_ref = socket1.get_io_service();
     (void)ios_ref;
 
+    ip::udp::socket::executor_type ex = socket1.get_executor();
+    (void)ex;
+
     // basic_socket functions.
 
     ip::udp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();