Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r84308 - in trunk: boost boost/asio boost/asio/detail boost/asio/detail/impl boost/asio/impl boost/asio/ip boost/asio/posix boost/asio/ssl boost/asio/ssl/detail boost/asio/windows libs/asio/doc libs/asio/doc/requirements libs/asio/test libs/asio/test/archetypes libs/asio/test/ip libs/asio/test/posix libs/asio/test/ssl libs/asio/test/windows
From: chris_at_[hidden]
Date: 2013-05-16 19:26:12


Author: chris_kohlhoff
Date: 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
New Revision: 84308
URL: http://svn.boost.org/trac/boost/changeset/84308

Log:
Add new traits classes, handler_type and async_result, that allow
the customisation of the return type of an initiating function.

Added:
   trunk/boost/asio/async_result.hpp (contents, props changed)
   trunk/boost/asio/handler_type.hpp (contents, props changed)
   trunk/libs/asio/test/archetypes/async_result.hpp (contents, props changed)
   trunk/libs/asio/test/ip/icmp.cpp (contents, props changed)
Text files modified:
   trunk/boost/asio.hpp | 2
   trunk/boost/asio/basic_datagram_socket.hpp | 60 +
   trunk/boost/asio/basic_deadline_timer.hpp | 6
   trunk/boost/asio/basic_raw_socket.hpp | 59 +
   trunk/boost/asio/basic_seq_packet_socket.hpp | 24
   trunk/boost/asio/basic_serial_port.hpp | 12
   trunk/boost/asio/basic_signal_set.hpp | 6
   trunk/boost/asio/basic_socket.hpp | 18
   trunk/boost/asio/basic_socket_acceptor.hpp | 12
   trunk/boost/asio/basic_stream_socket.hpp | 39 +
   trunk/boost/asio/basic_waitable_timer.hpp | 6
   trunk/boost/asio/connect.hpp | 17
   trunk/boost/asio/datagram_socket_service.hpp | 58 +
   trunk/boost/asio/deadline_timer_service.hpp | 13
   trunk/boost/asio/detail/deadline_timer_service.hpp | 2
   trunk/boost/asio/detail/handler_type_requirements.hpp | 178 ++++-
   trunk/boost/asio/detail/impl/strand_service.hpp | 4
   trunk/boost/asio/detail/impl/task_io_service.hpp | 4
   trunk/boost/asio/detail/impl/win_iocp_io_service.hpp | 4
   trunk/boost/asio/detail/reactive_descriptor_service.hpp | 8
   trunk/boost/asio/detail/reactive_serial_port_service.hpp | 4
   trunk/boost/asio/detail/reactive_socket_service.hpp | 12
   trunk/boost/asio/detail/resolver_service.hpp | 4
   trunk/boost/asio/detail/signal_set_service.hpp | 2
   trunk/boost/asio/detail/strand_service.hpp | 4
   trunk/boost/asio/detail/task_io_service.hpp | 4
   trunk/boost/asio/detail/win_iocp_handle_service.hpp | 16
   trunk/boost/asio/detail/win_iocp_io_service.hpp | 4
   trunk/boost/asio/detail/win_iocp_serial_port_service.hpp | 4
   trunk/boost/asio/detail/win_iocp_socket_service.hpp | 12
   trunk/boost/asio/impl/connect.hpp | 88 ++-
   trunk/boost/asio/impl/io_service.hpp | 23
   trunk/boost/asio/impl/read.hpp | 96 ++-
   trunk/boost/asio/impl/read_at.hpp | 89 ++-
   trunk/boost/asio/impl/read_until.hpp | 116 ++--
   trunk/boost/asio/impl/write.hpp | 86 +-
   trunk/boost/asio/impl/write_at.hpp | 68 +
   trunk/boost/asio/io_service.hpp | 7
   trunk/boost/asio/ip/basic_resolver.hpp | 8
   trunk/boost/asio/ip/resolver_service.hpp | 23
   trunk/boost/asio/posix/basic_stream_descriptor.hpp | 12
   trunk/boost/asio/posix/stream_descriptor_service.hpp | 23
   trunk/boost/asio/raw_socket_service.hpp | 58 +
   trunk/boost/asio/read.hpp | 17
   trunk/boost/asio/read_at.hpp | 17
   trunk/boost/asio/read_until.hpp | 17
   trunk/boost/asio/seq_packet_socket_service.hpp | 12
   trunk/boost/asio/serial_port_service.hpp | 23
   trunk/boost/asio/signal_set_service.hpp | 12
   trunk/boost/asio/socket_acceptor_service.hpp | 11
   trunk/boost/asio/ssl/detail/io.hpp | 2
   trunk/boost/asio/ssl/stream.hpp | 50 +
   trunk/boost/asio/strand.hpp | 23
   trunk/boost/asio/stream_socket_service.hpp | 34 +
   trunk/boost/asio/waitable_timer_service.hpp | 13
   trunk/boost/asio/windows/basic_object_handle.hpp | 7
   trunk/boost/asio/windows/basic_random_access_handle.hpp | 12
   trunk/boost/asio/windows/basic_stream_handle.hpp | 12
   trunk/boost/asio/windows/object_handle_service.hpp | 13
   trunk/boost/asio/windows/random_access_handle_service.hpp | 23
   trunk/boost/asio/windows/stream_handle_service.hpp | 23
   trunk/boost/asio/write.hpp | 17
   trunk/boost/asio/write_at.hpp | 17
   trunk/libs/asio/doc/reference.dox | 3
   trunk/libs/asio/doc/reference.xsl | 28
   trunk/libs/asio/doc/requirements/asynchronous_operations.qbk | 4
   trunk/libs/asio/test/Jamfile | 1
   trunk/libs/asio/test/Jamfile.v2 | 2
   trunk/libs/asio/test/deadline_timer.cpp | 14
   trunk/libs/asio/test/ip/tcp.cpp | 65 ++
   trunk/libs/asio/test/ip/udp.cpp | 80 +++
   trunk/libs/asio/test/posix/stream_descriptor.cpp | 12
   trunk/libs/asio/test/read.cpp | 88 +++
   trunk/libs/asio/test/read_at.cpp | 91 +++
   trunk/libs/asio/test/read_until.cpp | 25
   trunk/libs/asio/test/serial_port.cpp | 8
   trunk/libs/asio/test/signal_set.cpp | 4
   trunk/libs/asio/test/ssl/stream.cpp | 14
   trunk/libs/asio/test/windows/object_handle.cpp | 4
   trunk/libs/asio/test/windows/random_access_handle.cpp | 11
   trunk/libs/asio/test/windows/stream_handle.cpp | 8
   trunk/libs/asio/test/write.cpp | 556 ++++++++++++++++++++
   trunk/libs/asio/test/write_at.cpp | 1064 ++++++++++++++++++++++++++++++++++++++++
   83 files changed, 3217 insertions(+), 515 deletions(-)

Modified: trunk/boost/asio.hpp
==============================================================================
--- trunk/boost/asio.hpp (original)
+++ trunk/boost/asio.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 # pragma once
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/basic_datagram_socket.hpp>
 #include <boost/asio/basic_deadline_timer.hpp>
 #include <boost/asio/basic_io_object.hpp>
@@ -46,6 +47,7 @@
 #include <boost/asio/error.hpp>
 #include <boost/asio/handler_alloc_hook.hpp>
 #include <boost/asio/handler_invoke_hook.hpp>
+#include <boost/asio/handler_type.hpp>
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/ip/address.hpp>
 #include <boost/asio/ip/address_v4.hpp>

Added: trunk/boost/asio/async_result.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/async_result.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -0,0 +1,96 @@
+//
+// async_result.hpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2012 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)
+//
+
+#ifndef BOOST_ASIO_ASYNC_RESULT_HPP
+#define BOOST_ASIO_ASYNC_RESULT_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+#include <boost/asio/handler_type.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+
+/// An interface for customising the behaviour of an initiating function.
+/**
+ * This template may be specialised for user-defined handler types.
+ */
+template <typename Handler>
+class async_result
+{
+public:
+ /// The return type of the initiating function.
+ typedef void type;
+
+ /// Construct an async result from a given handler.
+ /**
+ * When using a specalised async_result, the constructor has an opportunity
+ * to initialise some state associated with the handler, which is then
+ * returned from the initiating function.
+ */
+ explicit async_result(Handler&)
+ {
+ }
+
+ /// Obtain the value to be returned from the initiating function.
+ type get()
+ {
+ }
+};
+
+namespace detail {
+
+// Helper template to deduce the true type of a handler, capture a local copy
+// of the handler, and then create an async_result for the handler.
+template <typename Handler, typename Signature>
+struct async_result_init
+{
+ explicit async_result_init(BOOST_ASIO_MOVE_ARG(Handler) orig_handler)
+ : handler(BOOST_ASIO_MOVE_CAST(Handler)(orig_handler)),
+ result(handler)
+ {
+ }
+
+ typename handler_type<Handler, Signature>::type handler;
+ async_result<typename handler_type<Handler, Signature>::type> result;
+};
+
+template <typename Handler, typename Signature>
+struct async_result_type_helper
+{
+ typedef typename async_result<
+ typename handler_type<Handler, Signature>::type
+ >::type type;
+};
+
+} // namespace detail
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#if defined(GENERATING_DOCUMENTATION)
+# define BOOST_ASIO_INITFN_RESULT_TYPE(h, sig) \
+ void_or_deduced
+#elif defined(_MSC_VER) && (_MSC_VER < 1500)
+# define BOOST_ASIO_INITFN_RESULT_TYPE(h, sig) \
+ typename ::boost::asio::detail::async_result_type_helper<h, sig>::type
+#else
+# define BOOST_ASIO_INITFN_RESULT_TYPE(h, sig) \
+ typename ::boost::asio::async_result< \
+ typename ::boost::asio::handler_type<h, sig>::type>::type
+#endif
+
+#endif // BOOST_ASIO_ASYNC_RESULT_HPP

Modified: trunk/boost/asio/basic_datagram_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_datagram_socket.hpp (original)
+++ trunk/boost/asio/basic_datagram_socket.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -290,14 +290,16 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send(const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send(this->get_implementation(),
+ return this->get_service().async_send(this->get_implementation(),
         buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -331,7 +333,9 @@
    * socket.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send(const ConstBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
@@ -339,7 +343,7 @@
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send(this->get_implementation(),
+ return this->get_service().async_send(this->get_implementation(),
         buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -469,7 +473,9 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send_to(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send_to(const ConstBufferSequence& buffers,
       const endpoint_type& destination,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
@@ -477,8 +483,9 @@
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send_to(this->get_implementation(), buffers,
- destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+ return this->get_service().async_send_to(
+ this->get_implementation(), buffers, destination, 0,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Start an asynchronous send.
@@ -509,7 +516,9 @@
    * boost::asio::io_service::post().
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send_to(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send_to(const ConstBufferSequence& buffers,
       const endpoint_type& destination, socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
@@ -517,8 +526,9 @@
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send_to(this->get_implementation(), buffers,
- destination, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+ return this->get_service().async_send_to(
+ this->get_implementation(), buffers, destination, flags,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Receive some data on a connected socket.
@@ -647,14 +657,16 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive(this->get_implementation(),
+ return this->get_service().async_receive(this->get_implementation(),
         buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
@@ -687,7 +699,9 @@
    * datagram socket.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(const MutableBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
@@ -695,7 +709,7 @@
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive(this->get_implementation(),
+ return this->get_service().async_receive(this->get_implementation(),
         buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
@@ -825,7 +839,9 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive_from(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive_from(const MutableBufferSequence& buffers,
       endpoint_type& sender_endpoint,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
@@ -833,8 +849,9 @@
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive_from(this->get_implementation(), buffers,
- sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+ return this->get_service().async_receive_from(
+ this->get_implementation(), buffers, sender_endpoint, 0,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Start an asynchronous receive.
@@ -867,7 +884,9 @@
    * boost::asio::io_service::post().
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive_from(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive_from(const MutableBufferSequence& buffers,
       endpoint_type& sender_endpoint, socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
@@ -875,8 +894,9 @@
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive_from(this->get_implementation(), buffers,
- sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+ return this->get_service().async_receive_from(
+ this->get_implementation(), buffers, sender_endpoint, flags,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/basic_deadline_timer.hpp
==============================================================================
--- trunk/boost/asio/basic_deadline_timer.hpp (original)
+++ trunk/boost/asio/basic_deadline_timer.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -492,13 +492,15 @@
    * boost::asio::io_service::post().
    */
   template <typename WaitHandler>
- void async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
+ BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
+ void (boost::system::error_code))
+ async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a WaitHandler.
     BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
 
- this->service.async_wait(this->implementation,
+ return this->service.async_wait(this->implementation,
         BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
   }
 };

Modified: trunk/boost/asio/basic_raw_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_raw_socket.hpp (original)
+++ trunk/boost/asio/basic_raw_socket.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -285,14 +285,16 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send(const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send(this->get_implementation(),
+ return this->get_service().async_send(this->get_implementation(),
         buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -325,7 +327,9 @@
    * socket.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send(const ConstBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
@@ -333,7 +337,7 @@
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send(this->get_implementation(),
+ return this->get_service().async_send(this->get_implementation(),
         buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -463,7 +467,9 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send_to(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send_to(const ConstBufferSequence& buffers,
       const endpoint_type& destination,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
@@ -471,8 +477,8 @@
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send_to(this->get_implementation(), buffers,
- destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+ return this->get_service().async_send_to(this->get_implementation(),
+ buffers, destination, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Start an asynchronous send.
@@ -503,7 +509,9 @@
    * boost::asio::io_service::post().
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send_to(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send_to(const ConstBufferSequence& buffers,
       const endpoint_type& destination, socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
@@ -511,8 +519,9 @@
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send_to(this->get_implementation(), buffers,
- destination, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+ return this->get_service().async_send_to(
+ this->get_implementation(), buffers, destination, flags,
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
   /// Receive some data on a connected socket.
@@ -641,14 +650,16 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive(this->get_implementation(),
+ return this->get_service().async_receive(this->get_implementation(),
         buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
@@ -681,7 +692,9 @@
    * raw socket.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(const MutableBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
@@ -689,7 +702,7 @@
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive(this->get_implementation(),
+ return this->get_service().async_receive(this->get_implementation(),
         buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
@@ -819,7 +832,9 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive_from(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive_from(const MutableBufferSequence& buffers,
       endpoint_type& sender_endpoint,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
@@ -827,8 +842,9 @@
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive_from(this->get_implementation(), buffers,
- sender_endpoint, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+ return this->get_service().async_receive_from(
+ this->get_implementation(), buffers, sender_endpoint, 0,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Start an asynchronous receive.
@@ -861,7 +877,9 @@
    * boost::asio::io_service::post().
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive_from(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive_from(const MutableBufferSequence& buffers,
       endpoint_type& sender_endpoint, socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
@@ -869,8 +887,9 @@
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive_from(this->get_implementation(), buffers,
- sender_endpoint, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+ return this->get_service().async_receive_from(
+ this->get_implementation(), buffers, sender_endpoint, flags,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/basic_seq_packet_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_seq_packet_socket.hpp (original)
+++ trunk/boost/asio/basic_seq_packet_socket.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -267,7 +267,9 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send(const ConstBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
@@ -275,7 +277,7 @@
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send(this->get_implementation(),
+ return this->get_service().async_send(this->get_implementation(),
         buffers, flags, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -437,7 +439,9 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(const MutableBufferSequence& buffers,
       socket_base::message_flags& out_flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
@@ -445,8 +449,9 @@
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive(this->get_implementation(), buffers,
- 0, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+ return this->get_service().async_receive(
+ this->get_implementation(), buffers, 0, out_flags,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
   /// Start an asynchronous receive.
@@ -492,7 +497,9 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(const MutableBufferSequence& buffers,
       socket_base::message_flags in_flags,
       socket_base::message_flags& out_flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
@@ -501,8 +508,9 @@
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive(this->get_implementation(), buffers,
- in_flags, out_flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+ return this->get_service().async_receive(
+ this->get_implementation(), buffers, in_flags, out_flags,
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/basic_serial_port.hpp
==============================================================================
--- trunk/boost/asio/basic_serial_port.hpp (original)
+++ trunk/boost/asio/basic_serial_port.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -559,14 +559,16 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some(const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_write_some(this->get_implementation(),
+ return this->get_service().async_write_some(this->get_implementation(),
         buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -670,14 +672,16 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some(const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_read_some(this->get_implementation(),
+ return this->get_service().async_read_some(this->get_implementation(),
         buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };

Modified: trunk/boost/asio/basic_signal_set.hpp
==============================================================================
--- trunk/boost/asio/basic_signal_set.hpp (original)
+++ trunk/boost/asio/basic_signal_set.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -365,13 +365,15 @@
    * boost::asio::io_service::post().
    */
   template <typename SignalHandler>
- void async_wait(BOOST_ASIO_MOVE_ARG(SignalHandler) handler)
+ BOOST_ASIO_INITFN_RESULT_TYPE(SignalHandler,
+ void (boost::system::error_code, int))
+ async_wait(BOOST_ASIO_MOVE_ARG(SignalHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a SignalHandler.
     BOOST_ASIO_SIGNAL_HANDLER_CHECK(SignalHandler, handler) type_check;
 
- this->service.async_wait(this->implementation,
+ return this->service.async_wait(this->implementation,
         BOOST_ASIO_MOVE_CAST(SignalHandler)(handler));
   }
 };

Modified: trunk/boost/asio/basic_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_socket.hpp (original)
+++ trunk/boost/asio/basic_socket.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -16,6 +16,7 @@
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
 #include <boost/asio/detail/config.hpp>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/basic_io_object.hpp>
 #include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
@@ -698,7 +699,9 @@
    * @endcode
    */
   template <typename ConnectHandler>
- void async_connect(const endpoint_type& peer_endpoint,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ConnectHandler,
+ void (boost::system::error_code))
+ async_connect(const endpoint_type& peer_endpoint,
       BOOST_ASIO_MOVE_ARG(ConnectHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
@@ -711,14 +714,21 @@
       const protocol_type protocol = peer_endpoint.protocol();
       if (this->get_service().open(this->get_implementation(), protocol, ec))
       {
+ detail::async_result_init<
+ ConnectHandler, void (boost::system::error_code)> init(
+ BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
+
         this->get_io_service().post(
             boost::asio::detail::bind_handler(
- BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler), ec));
- return;
+ BOOST_ASIO_MOVE_CAST(BOOST_ASIO_HANDLER_TYPE(
+ ConnectHandler, void (boost::system::error_code)))(
+ init.handler), ec));
+
+ return init.result.get();
       }
     }
 
- this->get_service().async_connect(this->get_implementation(),
+ return this->get_service().async_connect(this->get_implementation(),
         peer_endpoint, BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
   }
 

Modified: trunk/boost/asio/basic_socket_acceptor.hpp
==============================================================================
--- trunk/boost/asio/basic_socket_acceptor.hpp (original)
+++ trunk/boost/asio/basic_socket_acceptor.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -949,14 +949,16 @@
    * @endcode
    */
   template <typename SocketService, typename AcceptHandler>
- void async_accept(basic_socket<protocol_type, SocketService>& peer,
+ BOOST_ASIO_INITFN_RESULT_TYPE(AcceptHandler,
+ void (boost::system::error_code))
+ async_accept(basic_socket<protocol_type, SocketService>& peer,
       BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a AcceptHandler.
     BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;
 
- this->get_service().async_accept(this->get_implementation(),
+ return this->get_service().async_accept(this->get_implementation(),
         peer, 0, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
   }
 
@@ -1057,14 +1059,16 @@
    * boost::asio::io_service::post().
    */
   template <typename SocketService, typename AcceptHandler>
- void async_accept(basic_socket<protocol_type, SocketService>& peer,
+ BOOST_ASIO_INITFN_RESULT_TYPE(AcceptHandler,
+ void (boost::system::error_code))
+ async_accept(basic_socket<protocol_type, SocketService>& peer,
       endpoint_type& peer_endpoint, BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a AcceptHandler.
     BOOST_ASIO_ACCEPT_HANDLER_CHECK(AcceptHandler, handler) type_check;
 
- this->get_service().async_accept(this->get_implementation(), peer,
+ return this->get_service().async_accept(this->get_implementation(), peer,
         &peer_endpoint, BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
   }
 };

Modified: trunk/boost/asio/basic_stream_socket.hpp
==============================================================================
--- trunk/boost/asio/basic_stream_socket.hpp (original)
+++ trunk/boost/asio/basic_stream_socket.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/basic_socket.hpp>
 #include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/throw_error.hpp>
@@ -303,14 +304,17 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send(const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send(this->get_implementation(), buffers, 0,
+ return this->get_service().async_send(
+ this->get_implementation(), buffers, 0,
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -352,7 +356,9 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send(const ConstBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
@@ -360,7 +366,8 @@
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send(this->get_implementation(), buffers, flags,
+ return this->get_service().async_send(
+ this->get_implementation(), buffers, flags,
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -507,14 +514,16 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive(this->get_implementation(),
+ return this->get_service().async_receive(this->get_implementation(),
         buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
@@ -558,7 +567,9 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(const MutableBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
@@ -566,7 +577,7 @@
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive(this->get_implementation(),
+ return this->get_service().async_receive(this->get_implementation(),
         buffers, flags, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 
@@ -666,14 +677,16 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some(const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_send(this->get_implementation(),
+ return this->get_service().async_send(this->get_implementation(),
         buffers, 0, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -777,14 +790,16 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some(const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_receive(this->get_implementation(),
+ return this->get_service().async_receive(this->get_implementation(),
         buffers, 0, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };

Modified: trunk/boost/asio/basic_waitable_timer.hpp
==============================================================================
--- trunk/boost/asio/basic_waitable_timer.hpp (original)
+++ trunk/boost/asio/basic_waitable_timer.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -499,13 +499,15 @@
    * boost::asio::io_service::post().
    */
   template <typename WaitHandler>
- void async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
+ BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
+ void (boost::system::error_code))
+ async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a WaitHandler.
     BOOST_ASIO_WAIT_HANDLER_CHECK(WaitHandler, handler) type_check;
 
- this->service.async_wait(this->implementation,
+ return this->service.async_wait(this->implementation,
         BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
   }
 };

Modified: trunk/boost/asio/connect.hpp
==============================================================================
--- trunk/boost/asio/connect.hpp (original)
+++ trunk/boost/asio/connect.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -16,6 +16,7 @@
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
 #include <boost/asio/detail/config.hpp>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/basic_socket.hpp>
 #include <boost/asio/error.hpp>
 
@@ -516,7 +517,9 @@
  */
 template <typename Protocol, typename SocketService,
     typename Iterator, typename ComposedConnectHandler>
-void async_connect(basic_socket<Protocol, SocketService>& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
+ void (boost::system::error_code, Iterator))
+async_connect(basic_socket<Protocol, SocketService>& s,
     Iterator begin, BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
 
 /// Asynchronously establishes a socket connection by trying each endpoint in a
@@ -585,7 +588,9 @@
  */
 template <typename Protocol, typename SocketService,
     typename Iterator, typename ComposedConnectHandler>
-void async_connect(basic_socket<Protocol, SocketService>& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
+ void (boost::system::error_code, Iterator))
+async_connect(basic_socket<Protocol, SocketService>& s,
     Iterator begin, Iterator end,
     BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
 
@@ -693,7 +698,9 @@
  */
 template <typename Protocol, typename SocketService, typename Iterator,
     typename ConnectCondition, typename ComposedConnectHandler>
-void async_connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
+BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
+ void (boost::system::error_code, Iterator))
+async_connect(basic_socket<Protocol, SocketService>& s, Iterator begin,
     ConnectCondition connect_condition,
     BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
 
@@ -800,7 +807,9 @@
  */
 template <typename Protocol, typename SocketService, typename Iterator,
     typename ConnectCondition, typename ComposedConnectHandler>
-void async_connect(basic_socket<Protocol, SocketService>& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
+ void (boost::system::error_code, Iterator))
+async_connect(basic_socket<Protocol, SocketService>& s,
     Iterator begin, Iterator end, ConnectCondition connect_condition,
     BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler);
 

Modified: trunk/boost/asio/datagram_socket_service.hpp
==============================================================================
--- trunk/boost/asio/datagram_socket_service.hpp (original)
+++ trunk/boost/asio/datagram_socket_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
 
@@ -200,12 +201,19 @@
 
   /// Start an asynchronous connect.
   template <typename ConnectHandler>
- void async_connect(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ConnectHandler,
+ void (boost::system::error_code))
+ async_connect(implementation_type& impl,
       const endpoint_type& peer_endpoint,
       BOOST_ASIO_MOVE_ARG(ConnectHandler) handler)
   {
- service_impl_.async_connect(impl, peer_endpoint,
+ detail::async_result_init<
+ ConnectHandler, void (boost::system::error_code)> init(
         BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
+
+ service_impl_.async_connect(impl, peer_endpoint, init.handler);
+
+ return init.result.get();
   }
 
   /// Set a socket option.
@@ -290,12 +298,19 @@
 
   /// Start an asynchronous send.
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send(implementation_type& impl, const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send(implementation_type& impl, const ConstBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
- service_impl_.async_send(impl, buffers, flags,
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ service_impl_.async_send(impl, buffers, flags, init.handler);
+
+ return init.result.get();
   }
 
   /// Send a datagram to the specified endpoint.
@@ -309,13 +324,21 @@
 
   /// Start an asynchronous send.
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send_to(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send_to(implementation_type& impl,
       const ConstBufferSequence& buffers, const endpoint_type& destination,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
- service_impl_.async_send_to(impl, buffers, destination, flags,
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ service_impl_.async_send_to(impl, buffers,
+ destination, flags, init.handler);
+
+ return init.result.get();
   }
 
   /// Receive some data from the peer.
@@ -329,13 +352,20 @@
 
   /// Start an asynchronous receive.
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(implementation_type& impl,
       const MutableBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
- service_impl_.async_receive(impl, buffers, flags,
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ service_impl_.async_receive(impl, buffers, flags, init.handler);
+
+ return init.result.get();
   }
 
   /// Receive a datagram with the endpoint of the sender.
@@ -350,13 +380,21 @@
 
   /// Start an asynchronous receive that will get the endpoint of the sender.
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive_from(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive_from(implementation_type& impl,
       const MutableBufferSequence& buffers, endpoint_type& sender_endpoint,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
- service_impl_.async_receive_from(impl, buffers, sender_endpoint, flags,
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ service_impl_.async_receive_from(impl, buffers,
+ sender_endpoint, flags, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/deadline_timer_service.hpp
==============================================================================
--- trunk/boost/asio/deadline_timer_service.hpp (original)
+++ trunk/boost/asio/deadline_timer_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/detail/deadline_timer_service.hpp>
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/time_traits.hpp>
@@ -132,10 +133,18 @@
 
   // Start an asynchronous wait on the timer.
   template <typename WaitHandler>
- void async_wait(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
+ void (boost::system::error_code))
+ async_wait(implementation_type& impl,
       BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
   {
- service_impl_.async_wait(impl, BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
+ detail::async_result_init<
+ WaitHandler, void (boost::system::error_code)> init(
+ BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
+
+ service_impl_.async_wait(impl, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/detail/deadline_timer_service.hpp
==============================================================================
--- trunk/boost/asio/detail/deadline_timer_service.hpp (original)
+++ trunk/boost/asio/detail/deadline_timer_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -170,7 +170,7 @@
 
   // Start an asynchronous wait on the timer.
   template <typename Handler>
- void async_wait(implementation_type& impl, Handler handler)
+ void async_wait(implementation_type& impl, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef wait_handler<Handler> op;

Modified: trunk/boost/asio/detail/handler_type_requirements.hpp
==============================================================================
--- trunk/boost/asio/detail/handler_type_requirements.hpp (original)
+++ trunk/boost/asio/detail/handler_type_requirements.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -49,6 +49,10 @@
 # endif // defined(__clang__)
 #endif // !defined(BOOST_ASIO_DISABLE_HANDLER_TYPE_REQUIREMENTS)
 
+#if defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS)
+# include <boost/asio/handler_type.hpp>
+#endif // defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS)
+
 namespace boost {
 namespace asio {
 namespace detail {
@@ -98,6 +102,7 @@
 
 template <typename T> T& lvref();
 template <typename T> T& lvref(T);
+template <typename T> const T& clvref();
 template <typename T> const T& clvref(T);
 template <typename T> char argbyv(T);
 
@@ -109,25 +114,36 @@
 #define BOOST_ASIO_COMPLETION_HANDLER_CHECK( \
     handler_type, handler) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void()) asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::zero_arg_handler_test( \
- handler, 0)) == 1, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), 0)) == 1, \
       "CompletionHandler type requirements not met") \
   \
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)(), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()(), \
         char(0))>
 
 #define BOOST_ASIO_READ_HANDLER_CHECK( \
     handler_type, handler) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void(boost::system::error_code, std::size_t)) \
+ asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::two_arg_handler_test( \
- handler, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), \
           static_cast<const boost::system::error_code*>(0), \
           static_cast<const std::size_t*>(0))) == 1, \
       "ReadHandler type requirements not met") \
@@ -135,19 +151,27 @@
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)( \
- boost::asio::detail::lvref<const boost::system::error_code>(), \
- boost::asio::detail::lvref<const std::size_t>()), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()( \
+ boost::asio::detail::lvref<const boost::system::error_code>(), \
+ boost::asio::detail::lvref<const std::size_t>()), \
         char(0))>
 
+
 #define BOOST_ASIO_WRITE_HANDLER_CHECK( \
     handler_type, handler) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void(boost::system::error_code, std::size_t)) \
+ asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::two_arg_handler_test( \
- handler, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), \
           static_cast<const boost::system::error_code*>(0), \
           static_cast<const std::size_t*>(0))) == 1, \
       "WriteHandler type requirements not met") \
@@ -155,55 +179,76 @@
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)( \
- boost::asio::detail::lvref<const boost::system::error_code>(), \
- boost::asio::detail::lvref<const std::size_t>()), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()( \
+ boost::asio::detail::lvref<const boost::system::error_code>(), \
+ boost::asio::detail::lvref<const std::size_t>()), \
         char(0))>
 
 #define BOOST_ASIO_ACCEPT_HANDLER_CHECK( \
     handler_type, handler) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void(boost::system::error_code)) \
+ asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::one_arg_handler_test( \
- handler, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), \
           static_cast<const boost::system::error_code*>(0))) == 1, \
       "AcceptHandler type requirements not met") \
   \
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)( \
- boost::asio::detail::lvref<const boost::system::error_code>()), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()( \
+ boost::asio::detail::lvref<const boost::system::error_code>()), \
         char(0))>
 
 #define BOOST_ASIO_CONNECT_HANDLER_CHECK( \
     handler_type, handler) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void(boost::system::error_code)) \
+ asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::one_arg_handler_test( \
- handler, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), \
           static_cast<const boost::system::error_code*>(0))) == 1, \
       "ConnectHandler type requirements not met") \
   \
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)( \
- boost::asio::detail::lvref<const boost::system::error_code>()), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()( \
+ boost::asio::detail::lvref<const boost::system::error_code>()), \
         char(0))>
 
 #define BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK( \
     handler_type, handler, iter_type) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void(boost::system::error_code, iter_type)) \
+ asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::two_arg_handler_test( \
- handler, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), \
           static_cast<const boost::system::error_code*>(0), \
           static_cast<const iter_type*>(0))) == 1, \
       "ComposedConnectHandler type requirements not met") \
@@ -211,19 +256,26 @@
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)( \
- boost::asio::detail::lvref<const boost::system::error_code>(), \
- boost::asio::detail::lvref<const iter_type>()), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()( \
+ boost::asio::detail::lvref<const boost::system::error_code>(), \
+ boost::asio::detail::lvref<const iter_type>()), \
         char(0))>
 
 #define BOOST_ASIO_RESOLVE_HANDLER_CHECK( \
     handler_type, handler, iter_type) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void(boost::system::error_code, iter_type)) \
+ asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::two_arg_handler_test( \
- handler, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), \
           static_cast<const boost::system::error_code*>(0), \
           static_cast<const iter_type*>(0))) == 1, \
       "ResolveHandler type requirements not met") \
@@ -231,37 +283,51 @@
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)( \
- boost::asio::detail::lvref<const boost::system::error_code>(), \
- boost::asio::detail::lvref<const iter_type>()), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()( \
+ boost::asio::detail::lvref<const boost::system::error_code>(), \
+ boost::asio::detail::lvref<const iter_type>()), \
         char(0))>
 
 #define BOOST_ASIO_WAIT_HANDLER_CHECK( \
     handler_type, handler) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void(boost::system::error_code)) \
+ asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::one_arg_handler_test( \
- handler, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), \
           static_cast<const boost::system::error_code*>(0))) == 1, \
       "WaitHandler type requirements not met") \
   \
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)( \
- boost::asio::detail::lvref<const boost::system::error_code>()), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()( \
+ boost::asio::detail::lvref<const boost::system::error_code>()), \
         char(0))>
 
 #define BOOST_ASIO_SIGNAL_HANDLER_CHECK( \
     handler_type, handler) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void(boost::system::error_code, int)) \
+ asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::two_arg_handler_test( \
- handler, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), \
           static_cast<const boost::system::error_code*>(0), \
           static_cast<const int*>(0))) == 1, \
       "SignalHandler type requirements not met") \
@@ -269,47 +335,63 @@
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)( \
- boost::asio::detail::lvref<const boost::system::error_code>(), \
- boost::asio::detail::lvref<const int>()), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()( \
+ boost::asio::detail::lvref<const boost::system::error_code>(), \
+ boost::asio::detail::lvref<const int>()), \
         char(0))>
 
 #define BOOST_ASIO_HANDSHAKE_HANDLER_CHECK( \
     handler_type, handler) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void(boost::system::error_code)) \
+ asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::one_arg_handler_test( \
- handler, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), \
           static_cast<const boost::system::error_code*>(0))) == 1, \
       "HandshakeHandler type requirements not met") \
   \
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)( \
- boost::asio::detail::lvref<const boost::system::error_code>()), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()( \
+ boost::asio::detail::lvref<const boost::system::error_code>()), \
         char(0))>
 
 #define BOOST_ASIO_SHUTDOWN_HANDLER_CHECK( \
     handler_type, handler) \
   \
+ typedef BOOST_ASIO_HANDLER_TYPE(handler_type, \
+ void(boost::system::error_code)) \
+ asio_true_handler_type; \
+ \
   BOOST_ASIO_HANDLER_TYPE_REQUIREMENTS_ASSERT( \
       sizeof(boost::asio::detail::one_arg_handler_test( \
- handler, \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>(), \
           static_cast<const boost::system::error_code*>(0))) == 1, \
       "ShutdownHandler type requirements not met") \
   \
   typedef boost::asio::detail::handler_type_requirements< \
       sizeof( \
         boost::asio::detail::argbyv( \
- boost::asio::detail::clvref(handler))) + \
+ boost::asio::detail::clvref< \
+ asio_true_handler_type>())) + \
       sizeof( \
- boost::asio::detail::lvref(handler)( \
- boost::asio::detail::lvref<const boost::system::error_code>()), \
+ boost::asio::detail::lvref< \
+ asio_true_handler_type>()( \
+ boost::asio::detail::lvref<const boost::system::error_code>()), \
         char(0))>
 
 #else // !defined(BOOST_ASIO_ENABLE_HANDLER_TYPE_REQUIREMENTS)

Modified: trunk/boost/asio/detail/impl/strand_service.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/strand_service.hpp (original)
+++ trunk/boost/asio/detail/impl/strand_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -52,7 +52,7 @@
 
 template <typename Handler>
 void strand_service::dispatch(strand_service::implementation_type& impl,
- Handler handler)
+ Handler& handler)
 {
   // If we are already in the strand then the handler can run immediately.
   if (call_stack<strand_impl>::contains(impl))
@@ -92,7 +92,7 @@
 // Request the io_service to invoke the given handler and return immediately.
 template <typename Handler>
 void strand_service::post(strand_service::implementation_type& impl,
- Handler handler)
+ Handler& handler)
 {
   // Allocate and construct an operation to wrap the handler.
   typedef completion_handler<Handler> op;

Modified: trunk/boost/asio/detail/impl/task_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/task_io_service.hpp (original)
+++ trunk/boost/asio/detail/impl/task_io_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -27,7 +27,7 @@
 namespace detail {
 
 template <typename Handler>
-void task_io_service::dispatch(Handler handler)
+void task_io_service::dispatch(Handler& handler)
 {
   if (thread_call_stack::contains(this))
   {
@@ -51,7 +51,7 @@
 }
 
 template <typename Handler>
-void task_io_service::post(Handler handler)
+void task_io_service::post(Handler& handler)
 {
   // Allocate and construct an operation to wrap the handler.
   typedef completion_handler<Handler> op;

Modified: trunk/boost/asio/detail/impl/win_iocp_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/impl/win_iocp_io_service.hpp (original)
+++ trunk/boost/asio/detail/impl/win_iocp_io_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -31,7 +31,7 @@
 namespace detail {
 
 template <typename Handler>
-void win_iocp_io_service::dispatch(Handler handler)
+void win_iocp_io_service::dispatch(Handler& handler)
 {
   if (thread_call_stack::contains(this))
   {
@@ -55,7 +55,7 @@
 }
 
 template <typename Handler>
-void win_iocp_io_service::post(Handler handler)
+void win_iocp_io_service::post(Handler& handler)
 {
   // Allocate and construct an operation to wrap the handler.
   typedef completion_handler<Handler> op;

Modified: trunk/boost/asio/detail/reactive_descriptor_service.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_descriptor_service.hpp (original)
+++ trunk/boost/asio/detail/reactive_descriptor_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -186,7 +186,7 @@
   // lifetime of the asynchronous operation.
   template <typename ConstBufferSequence, typename Handler>
   void async_write_some(implementation_type& impl,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef descriptor_write_op<ConstBufferSequence, Handler> op;
@@ -206,7 +206,7 @@
   // Start an asynchronous wait until data can be written without blocking.
   template <typename Handler>
   void async_write_some(implementation_type& impl,
- const null_buffers&, Handler handler)
+ const null_buffers&, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_null_buffers_op<Handler> op;
@@ -248,7 +248,7 @@
   // valid for the lifetime of the asynchronous operation.
   template <typename MutableBufferSequence, typename Handler>
   void async_read_some(implementation_type& impl,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef descriptor_read_op<MutableBufferSequence, Handler> op;
@@ -268,7 +268,7 @@
   // Wait until data can be read without blocking.
   template <typename Handler>
   void async_read_some(implementation_type& impl,
- const null_buffers&, Handler handler)
+ const null_buffers&, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_null_buffers_op<Handler> op;

Modified: trunk/boost/asio/detail/reactive_serial_port_service.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_serial_port_service.hpp (original)
+++ trunk/boost/asio/detail/reactive_serial_port_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -158,7 +158,7 @@
   // lifetime of the asynchronous operation.
   template <typename ConstBufferSequence, typename Handler>
   void async_write_some(implementation_type& impl,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
   {
     descriptor_service_.async_write_some(impl, buffers, handler);
   }
@@ -175,7 +175,7 @@
   // valid for the lifetime of the asynchronous operation.
   template <typename MutableBufferSequence, typename Handler>
   void async_read_some(implementation_type& impl,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
   {
     descriptor_service_.async_read_some(impl, buffers, handler);
   }

Modified: trunk/boost/asio/detail/reactive_socket_service.hpp
==============================================================================
--- trunk/boost/asio/detail/reactive_socket_service.hpp (original)
+++ trunk/boost/asio/detail/reactive_socket_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -215,7 +215,7 @@
   void async_send_to(implementation_type& impl,
       const ConstBufferSequence& buffers,
       const endpoint_type& destination, socket_base::message_flags flags,
- Handler handler)
+ Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_sendto_op<ConstBufferSequence,
@@ -234,7 +234,7 @@
   // Start an asynchronous wait until data can be sent without blocking.
   template <typename Handler>
   void async_send_to(implementation_type& impl, const null_buffers&,
- const endpoint_type&, socket_base::message_flags, Handler handler)
+ const endpoint_type&, socket_base::message_flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_null_buffers_op<Handler> op;
@@ -292,7 +292,7 @@
   template <typename MutableBufferSequence, typename Handler>
   void async_receive_from(implementation_type& impl,
       const MutableBufferSequence& buffers, endpoint_type& sender_endpoint,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_recvfrom_op<MutableBufferSequence,
@@ -318,7 +318,7 @@
   template <typename Handler>
   void async_receive_from(implementation_type& impl,
       const null_buffers&, endpoint_type& sender_endpoint,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_null_buffers_op<Handler> op;
@@ -373,7 +373,7 @@
   // must be valid until the accept's handler is invoked.
   template <typename Socket, typename Handler>
   void async_accept(implementation_type& impl, Socket& peer,
- endpoint_type* peer_endpoint, Handler handler)
+ endpoint_type* peer_endpoint, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_accept_op<Socket, Protocol, Handler> op;
@@ -401,7 +401,7 @@
   // Start an asynchronous connect.
   template <typename Handler>
   void async_connect(implementation_type& impl,
- const endpoint_type& peer_endpoint, Handler handler)
+ const endpoint_type& peer_endpoint, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_connect_op<Handler> op;

Modified: trunk/boost/asio/detail/resolver_service.hpp
==============================================================================
--- trunk/boost/asio/detail/resolver_service.hpp (original)
+++ trunk/boost/asio/detail/resolver_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -68,7 +68,7 @@
   // Asynchronously resolve a query to a list of entries.
   template <typename Handler>
   void async_resolve(implementation_type& impl,
- const query_type& query, Handler handler)
+ const query_type& query, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef resolve_op<Protocol, Handler> op;
@@ -100,7 +100,7 @@
   // Asynchronously resolve an endpoint to a list of entries.
   template <typename Handler>
   void async_resolve(implementation_type& impl,
- const endpoint_type& endpoint, Handler handler)
+ const endpoint_type& endpoint, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef resolve_endpoint_op<Protocol, Handler> op;

Modified: trunk/boost/asio/detail/signal_set_service.hpp
==============================================================================
--- trunk/boost/asio/detail/signal_set_service.hpp (original)
+++ trunk/boost/asio/detail/signal_set_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -144,7 +144,7 @@
 
   // Start an asynchronous operation to wait for a signal to be delivered.
   template <typename Handler>
- void async_wait(implementation_type& impl, Handler handler)
+ void async_wait(implementation_type& impl, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef signal_handler<Handler> op;

Modified: trunk/boost/asio/detail/strand_service.hpp
==============================================================================
--- trunk/boost/asio/detail/strand_service.hpp (original)
+++ trunk/boost/asio/detail/strand_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -86,11 +86,11 @@
 
   // Request the io_service to invoke the given handler.
   template <typename Handler>
- void dispatch(implementation_type& impl, Handler handler);
+ void dispatch(implementation_type& impl, Handler& handler);
 
   // Request the io_service to invoke the given handler and return immediately.
   template <typename Handler>
- void post(implementation_type& impl, Handler handler);
+ void post(implementation_type& impl, Handler& handler);
 
 private:
   // Helper function to dispatch a handler. Returns true if the handler should

Modified: trunk/boost/asio/detail/task_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/task_io_service.hpp (original)
+++ trunk/boost/asio/detail/task_io_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -94,11 +94,11 @@
 
   // Request invocation of the given handler.
   template <typename Handler>
- void dispatch(Handler handler);
+ void dispatch(Handler& handler);
 
   // Request invocation of the given handler and return immediately.
   template <typename Handler>
- void post(Handler handler);
+ void post(Handler& handler);
 
   // Request invocation of the given operation and return immediately. Assumes
   // that work_started() has not yet been called for the operation.

Modified: trunk/boost/asio/detail/win_iocp_handle_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_handle_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_handle_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -143,7 +143,7 @@
   // lifetime of the asynchronous operation.
   template <typename ConstBufferSequence, typename Handler>
   void async_write_some(implementation_type& impl,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_handle_write_op<ConstBufferSequence, Handler> op;
@@ -164,7 +164,7 @@
   // must be valid for the lifetime of the asynchronous operation.
   template <typename ConstBufferSequence, typename Handler>
   void async_write_some_at(implementation_type& impl, boost::uint64_t offset,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_handle_write_op<ConstBufferSequence, Handler> op;
@@ -205,7 +205,7 @@
   // valid for the lifetime of the asynchronous operation.
   template <typename MutableBufferSequence, typename Handler>
   void async_read_some(implementation_type& impl,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_handle_read_op<MutableBufferSequence, Handler> op;
@@ -227,7 +227,7 @@
   // operation.
   template <typename MutableBufferSequence, typename Handler>
   void async_read_some_at(implementation_type& impl, boost::uint64_t offset,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_handle_read_op<MutableBufferSequence, Handler> op;
@@ -252,20 +252,20 @@
       const null_buffers& buffers, boost::system::error_code& ec);
   template <typename Handler>
   void async_write_some(implementation_type& impl,
- const null_buffers& buffers, Handler handler);
+ const null_buffers& buffers, Handler& handler);
   template <typename Handler>
   void async_write_some_at(implementation_type& impl, boost::uint64_t offset,
- const null_buffers& buffers, Handler handler);
+ const null_buffers& buffers, Handler& handler);
   size_t read_some(implementation_type& impl,
       const null_buffers& buffers, boost::system::error_code& ec);
   size_t read_some_at(implementation_type& impl, boost::uint64_t offset,
       const null_buffers& buffers, boost::system::error_code& ec);
   template <typename Handler>
   void async_read_some(implementation_type& impl,
- const null_buffers& buffers, Handler handler);
+ const null_buffers& buffers, Handler& handler);
   template <typename Handler>
   void async_read_some_at(implementation_type& impl, boost::uint64_t offset,
- const null_buffers& buffers, Handler handler);
+ const null_buffers& buffers, Handler& handler);
 
   // Helper class for waiting for synchronous operations to complete.
   class overlapped_wrapper;

Modified: trunk/boost/asio/detail/win_iocp_io_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_io_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_io_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -113,11 +113,11 @@
 
   // Request invocation of the given handler.
   template <typename Handler>
- void dispatch(Handler handler);
+ void dispatch(Handler& handler);
 
   // Request invocation of the given handler and return immediately.
   template <typename Handler>
- void post(Handler handler);
+ void post(Handler& handler);
 
   // Request invocation of the given operation and return immediately. Assumes
   // that work_started() has not yet been called for the operation.

Modified: trunk/boost/asio/detail/win_iocp_serial_port_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_serial_port_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_serial_port_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -153,7 +153,7 @@
   // lifetime of the asynchronous operation.
   template <typename ConstBufferSequence, typename Handler>
   void async_write_some(implementation_type& impl,
- const ConstBufferSequence& buffers, Handler handler)
+ const ConstBufferSequence& buffers, Handler& handler)
   {
     handle_service_.async_write_some(impl, buffers, handler);
   }
@@ -170,7 +170,7 @@
   // valid for the lifetime of the asynchronous operation.
   template <typename MutableBufferSequence, typename Handler>
   void async_read_some(implementation_type& impl,
- const MutableBufferSequence& buffers, Handler handler)
+ const MutableBufferSequence& buffers, Handler& handler)
   {
     handle_service_.async_read_some(impl, buffers, handler);
   }

Modified: trunk/boost/asio/detail/win_iocp_socket_service.hpp
==============================================================================
--- trunk/boost/asio/detail/win_iocp_socket_service.hpp (original)
+++ trunk/boost/asio/detail/win_iocp_socket_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -291,7 +291,7 @@
   template <typename ConstBufferSequence, typename Handler>
   void async_send_to(implementation_type& impl,
       const ConstBufferSequence& buffers, const endpoint_type& destination,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_socket_send_op<ConstBufferSequence, Handler> op;
@@ -314,7 +314,7 @@
   // Start an asynchronous wait until data can be sent without blocking.
   template <typename Handler>
   void async_send_to(implementation_type& impl, const null_buffers&,
- const endpoint_type&, socket_base::message_flags, Handler handler)
+ const endpoint_type&, socket_base::message_flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_null_buffers_op<Handler> op;
@@ -372,7 +372,7 @@
   template <typename MutableBufferSequence, typename Handler>
   void async_receive_from(implementation_type& impl,
       const MutableBufferSequence& buffers, endpoint_type& sender_endp,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_socket_recvfrom_op<
@@ -396,7 +396,7 @@
   template <typename Handler>
   void async_receive_from(implementation_type& impl,
       const null_buffers&, endpoint_type& sender_endpoint,
- socket_base::message_flags flags, Handler handler)
+ socket_base::message_flags flags, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_null_buffers_op<Handler> op;
@@ -448,7 +448,7 @@
   // must be valid until the accept's handler is invoked.
   template <typename Socket, typename Handler>
   void async_accept(implementation_type& impl, Socket& peer,
- endpoint_type* peer_endpoint, Handler handler)
+ endpoint_type* peer_endpoint, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef win_iocp_socket_accept_op<Socket, protocol_type, Handler> op;
@@ -481,7 +481,7 @@
   // Start an asynchronous connect.
   template <typename Handler>
   void async_connect(implementation_type& impl,
- const endpoint_type& peer_endpoint, Handler handler)
+ const endpoint_type& peer_endpoint, Handler& handler)
   {
     // Allocate and construct an operation to wrap the handler.
     typedef reactive_socket_connect_op<Handler> op;

Added: trunk/boost/asio/handler_type.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/asio/handler_type.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -0,0 +1,110 @@
+//
+// handler_type.hpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2012 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)
+//
+
+#ifndef BOOST_ASIO_HANDLER_TYPE_HPP
+#define BOOST_ASIO_HANDLER_TYPE_HPP
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1200)
+# pragma once
+#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
+
+#include <boost/asio/detail/config.hpp>
+
+#include <boost/asio/detail/push_options.hpp>
+
+namespace boost {
+namespace asio {
+
+/// Default handler type traits provided for all handlers.
+/**
+ * The handler_type traits class is used for determining the concrete handler
+ * type to be used for an asynchronous operation. It allows the handler type to
+ * be determined at the point where the specific completion handler signature
+ * is known.
+ *
+ * This template may be specialised for user-defined handler types.
+ */
+template <typename Handler, typename Signature>
+struct handler_type
+{
+ /// The handler type for the specific signature.
+ typedef Handler type;
+};
+
+template <typename Handler, typename Signature>
+struct handler_type<const Handler, Signature>
+ : handler_type<Handler, Signature> {};
+
+template <typename Handler, typename Signature>
+struct handler_type<volatile Handler, Signature>
+ : handler_type<Handler, Signature> {};
+
+template <typename Handler, typename Signature>
+struct handler_type<const volatile Handler, Signature>
+ : handler_type<Handler, Signature> {};
+
+template <typename Handler, typename Signature>
+struct handler_type<const Handler&, Signature>
+ : handler_type<Handler, Signature> {};
+
+template <typename Handler, typename Signature>
+struct handler_type<volatile Handler&, Signature>
+ : handler_type<Handler, Signature> {};
+
+template <typename Handler, typename Signature>
+struct handler_type<const volatile Handler&, Signature>
+ : handler_type<Handler, Signature> {};
+
+template <typename Handler, typename Signature>
+struct handler_type<Handler&, Signature>
+ : handler_type<Handler, Signature> {};
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+template <typename Handler, typename Signature>
+struct handler_type<Handler&&, Signature>
+ : handler_type<Handler, Signature> {};
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+template <typename ReturnType, typename Signature>
+struct handler_type<ReturnType(), Signature>
+ : handler_type<ReturnType(*)(), Signature> {};
+
+template <typename ReturnType, typename Arg1, typename Signature>
+struct handler_type<ReturnType(Arg1), Signature>
+ : handler_type<ReturnType(*)(Arg1), Signature> {};
+
+template <typename ReturnType, typename Arg1, typename Arg2, typename Signature>
+struct handler_type<ReturnType(Arg1, Arg2), Signature>
+ : handler_type<ReturnType(*)(Arg1, Arg2), Signature> {};
+
+template <typename ReturnType, typename Arg1, typename Arg2, typename Arg3,
+ typename Signature>
+struct handler_type<ReturnType(Arg1, Arg2, Arg3), Signature>
+ : handler_type<ReturnType(*)(Arg1, Arg2, Arg3), Signature> {};
+
+template <typename ReturnType, typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Signature>
+struct handler_type<ReturnType(Arg1, Arg2, Arg3, Arg4), Signature>
+ : handler_type<ReturnType(*)(Arg1, Arg2, Arg3, Arg4), Signature> {};
+
+template <typename ReturnType, typename Arg1, typename Arg2, typename Arg3,
+ typename Arg4, typename Arg5, typename Signature>
+struct handler_type<ReturnType(Arg1, Arg2, Arg3, Arg4, Arg5), Signature>
+ : handler_type<ReturnType(*)(Arg1, Arg2, Arg3, Arg4, Arg5), Signature> {};
+
+} // namespace asio
+} // namespace boost
+
+#include <boost/asio/detail/pop_options.hpp>
+
+#define BOOST_ASIO_HANDLER_TYPE(h, sig) \
+ typename handler_type<h, sig>::type
+
+#endif // BOOST_ASIO_HANDLER_TYPE_HPP

Modified: trunk/boost/asio/impl/connect.hpp
==============================================================================
--- trunk/boost/asio/impl/connect.hpp (original)
+++ trunk/boost/asio/impl/connect.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -302,25 +302,13 @@
     boost_asio_handler_invoke_helpers::invoke(
         function, this_handler->handler_);
   }
-
- template <typename Protocol, typename SocketService, typename Iterator,
- typename ConnectCondition, typename ComposedConnectHandler>
- inline connect_op<Protocol, SocketService, Iterator,
- ConnectCondition, ComposedConnectHandler>
- make_connect_op(basic_socket<Protocol, SocketService>& sock,
- const Iterator& begin, const Iterator& end,
- const ConnectCondition& connect_condition,
- ComposedConnectHandler handler)
- {
- return connect_op<Protocol, SocketService, Iterator,
- ConnectCondition, ComposedConnectHandler>(
- sock, begin, end, connect_condition, handler);
- }
 } // namespace detail
 
 template <typename Protocol, typename SocketService,
     typename Iterator, typename ComposedConnectHandler>
-inline void async_connect(basic_socket<Protocol, SocketService>& s,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
+ void (boost::system::error_code, Iterator))
+async_connect(basic_socket<Protocol, SocketService>& s,
     Iterator begin, BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler)
 {
   // If you get an error on the following line it means that your handler does
@@ -328,15 +316,24 @@
   BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
       ComposedConnectHandler, handler, Iterator) type_check;
 
- detail::make_connect_op(s, begin, Iterator(),
- detail::default_connect_condition(),
- BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler))(
- boost::system::error_code(), 1);
+ detail::async_result_init<ComposedConnectHandler,
+ void (boost::system::error_code, Iterator)> init(
+ BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler));
+
+ detail::connect_op<Protocol, SocketService, Iterator,
+ detail::default_connect_condition, BOOST_ASIO_HANDLER_TYPE(
+ ComposedConnectHandler, void (boost::system::error_code, Iterator))>(s,
+ begin, Iterator(), detail::default_connect_condition(), init.handler)(
+ boost::system::error_code(), 1);
+
+ return init.result.get();
 }
 
 template <typename Protocol, typename SocketService,
     typename Iterator, typename ComposedConnectHandler>
-inline void async_connect(basic_socket<Protocol, SocketService>& s,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
+ void (boost::system::error_code, Iterator))
+async_connect(basic_socket<Protocol, SocketService>& s,
     Iterator begin, Iterator end,
     BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler)
 {
@@ -345,15 +342,24 @@
   BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
       ComposedConnectHandler, handler, Iterator) type_check;
 
- detail::make_connect_op(s, begin, end,
- detail::default_connect_condition(),
- BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler))(
- boost::system::error_code(), 1);
+ detail::async_result_init<ComposedConnectHandler,
+ void (boost::system::error_code, Iterator)> init(
+ BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler));
+
+ detail::connect_op<Protocol, SocketService, Iterator,
+ detail::default_connect_condition, BOOST_ASIO_HANDLER_TYPE(
+ ComposedConnectHandler, void (boost::system::error_code, Iterator))>(s,
+ begin, end, detail::default_connect_condition(), init.handler)(
+ boost::system::error_code(), 1);
+
+ return init.result.get();
 }
 
 template <typename Protocol, typename SocketService, typename Iterator,
     typename ConnectCondition, typename ComposedConnectHandler>
-inline void async_connect(basic_socket<Protocol, SocketService>& s,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
+ void (boost::system::error_code, Iterator))
+async_connect(basic_socket<Protocol, SocketService>& s,
     Iterator begin, ConnectCondition connect_condition,
     BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler)
 {
@@ -362,14 +368,24 @@
   BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
       ComposedConnectHandler, handler, Iterator) type_check;
 
- detail::make_connect_op(s, begin, Iterator(), connect_condition,
- BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler))(
- boost::system::error_code(), 1);
+ detail::async_result_init<ComposedConnectHandler,
+ void (boost::system::error_code, Iterator)> init(
+ BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler));
+
+ detail::connect_op<Protocol, SocketService, Iterator,
+ ConnectCondition, BOOST_ASIO_HANDLER_TYPE(
+ ComposedConnectHandler, void (boost::system::error_code, Iterator))>(s,
+ begin, Iterator(), connect_condition, init.handler)(
+ boost::system::error_code(), 1);
+
+ return init.result.get();
 }
 
 template <typename Protocol, typename SocketService, typename Iterator,
     typename ConnectCondition, typename ComposedConnectHandler>
-void async_connect(basic_socket<Protocol, SocketService>& s,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ComposedConnectHandler,
+ void (boost::system::error_code, Iterator))
+async_connect(basic_socket<Protocol, SocketService>& s,
     Iterator begin, Iterator end, ConnectCondition connect_condition,
     BOOST_ASIO_MOVE_ARG(ComposedConnectHandler) handler)
 {
@@ -378,9 +394,17 @@
   BOOST_ASIO_COMPOSED_CONNECT_HANDLER_CHECK(
       ComposedConnectHandler, handler, Iterator) type_check;
 
- detail::make_connect_op(s, begin, end, connect_condition,
- BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler))(
- boost::system::error_code(), 1);
+ detail::async_result_init<ComposedConnectHandler,
+ void (boost::system::error_code, Iterator)> init(
+ BOOST_ASIO_MOVE_CAST(ComposedConnectHandler)(handler));
+
+ detail::connect_op<Protocol, SocketService, Iterator,
+ ConnectCondition, BOOST_ASIO_HANDLER_TYPE(
+ ComposedConnectHandler, void (boost::system::error_code, Iterator))>(s,
+ begin, end, connect_condition, init.handler)(
+ boost::system::error_code(), 1);
+
+ return init.result.get();
 }
 
 } // namespace asio

Modified: trunk/boost/asio/impl/io_service.hpp
==============================================================================
--- trunk/boost/asio/impl/io_service.hpp (original)
+++ trunk/boost/asio/impl/io_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -77,24 +77,37 @@
 namespace asio {
 
 template <typename CompletionHandler>
-inline void io_service::dispatch(
- BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
+inline BOOST_ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
+io_service::dispatch(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
 {
   // If you get an error on the following line it means that your handler does
   // not meet the documented type requirements for a CompletionHandler.
   BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
 
- impl_.dispatch(BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+ detail::async_result_init<
+ CompletionHandler, void ()> init(
+ BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+
+ impl_.dispatch(init.handler);
+
+ return init.result.get();
 }
 
 template <typename CompletionHandler>
-inline void io_service::post(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
+inline BOOST_ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
+io_service::post(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
 {
   // If you get an error on the following line it means that your handler does
   // not meet the documented type requirements for a CompletionHandler.
   BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
 
- impl_.post(BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+ detail::async_result_init<
+ CompletionHandler, void ()> init(
+ BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+
+ impl_.post(init.handler);
+
+ return init.result.get();
 }
 
 template <typename Handler>

Modified: trunk/boost/asio/impl/read.hpp
==============================================================================
--- trunk/boost/asio/impl/read.hpp (original)
+++ trunk/boost/asio/impl/read.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -485,22 +485,13 @@
     boost_asio_handler_invoke_helpers::invoke(
         function, this_handler->handler_);
   }
-
- template <typename AsyncReadStream, typename MutableBufferSequence,
- typename CompletionCondition, typename ReadHandler>
- inline read_op<AsyncReadStream, MutableBufferSequence,
- CompletionCondition, ReadHandler>
- make_read_op(AsyncReadStream& s, const MutableBufferSequence& buffers,
- CompletionCondition completion_condition, ReadHandler handler)
- {
- return read_op<AsyncReadStream, MutableBufferSequence, CompletionCondition,
- ReadHandler>(s, buffers, completion_condition, handler);
- }
 } // namespace detail
 
 template <typename AsyncReadStream, typename MutableBufferSequence,
     typename CompletionCondition, typename ReadHandler>
-inline void async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
 {
@@ -508,24 +499,41 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_op(
- s, buffers, completion_condition,
- BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_op<AsyncReadStream, MutableBufferSequence,
+ CompletionCondition, BOOST_ASIO_HANDLER_TYPE(
+ ReadHandler, void (boost::system::error_code, std::size_t))>(
+ s, buffers, completion_condition, init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 template <typename AsyncReadStream, typename MutableBufferSequence,
     typename ReadHandler>
-inline void async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
 {
   // If you get an error on the following line it means that your handler does
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_op(
- s, buffers, transfer_all(), BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_op<AsyncReadStream, MutableBufferSequence,
+ detail::transfer_all_t, BOOST_ASIO_HANDLER_TYPE(
+ ReadHandler, void (boost::system::error_code, std::size_t))>(
+ s, buffers, transfer_all(), init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 #if !defined(BOOST_NO_IOSTREAM)
@@ -642,23 +650,13 @@
     boost_asio_handler_invoke_helpers::invoke(
         function, this_handler->handler_);
   }
-
- template <typename AsyncReadStream, typename Allocator,
- typename CompletionCondition, typename ReadHandler>
- inline read_streambuf_op<AsyncReadStream, Allocator,
- CompletionCondition, ReadHandler>
- make_read_streambuf_op(
- AsyncReadStream& s, boost::asio::basic_streambuf<Allocator>& b,
- CompletionCondition completion_condition, ReadHandler handler)
- {
- return read_streambuf_op<AsyncReadStream, Allocator, CompletionCondition,
- ReadHandler>(s, b, completion_condition, handler);
- }
 } // namespace detail
 
 template <typename AsyncReadStream, typename Allocator,
     typename CompletionCondition, typename ReadHandler>
-inline void async_read(AsyncReadStream& s,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
@@ -667,13 +665,23 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_streambuf_op(
- s, b, completion_condition, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_streambuf_op<AsyncReadStream, Allocator,
+ CompletionCondition, BOOST_ASIO_HANDLER_TYPE(
+ ReadHandler, void (boost::system::error_code, std::size_t))>(
+ s, b, completion_condition, init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-inline void async_read(AsyncReadStream& s,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
 {
@@ -681,9 +689,17 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_streambuf_op(
- s, b, transfer_all(), BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_streambuf_op<AsyncReadStream, Allocator,
+ detail::transfer_all_t, BOOST_ASIO_HANDLER_TYPE(
+ ReadHandler, void (boost::system::error_code, std::size_t))>(
+ s, b, transfer_all(), init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 #endif // !defined(BOOST_NO_IOSTREAM)

Modified: trunk/boost/asio/impl/read_at.hpp
==============================================================================
--- trunk/boost/asio/impl/read_at.hpp (original)
+++ trunk/boost/asio/impl/read_at.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -537,7 +537,9 @@
 
 template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
     typename CompletionCondition, typename ReadHandler>
-inline void async_read_at(AsyncRandomAccessReadDevice& d,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_at(AsyncRandomAccessReadDevice& d,
     boost::uint64_t offset, const MutableBufferSequence& buffers,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
@@ -546,15 +548,24 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_at_op(
- d, offset, buffers, completion_condition,
- BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
+ CompletionCondition, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))>(
+ d, offset, buffers, completion_condition, init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
     typename ReadHandler>
-inline void async_read_at(AsyncRandomAccessReadDevice& d,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_at(AsyncRandomAccessReadDevice& d,
     boost::uint64_t offset, const MutableBufferSequence& buffers,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
 {
@@ -562,10 +573,17 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_at_op(
- d, offset, buffers, transfer_all(),
- BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_at_op<AsyncRandomAccessReadDevice, MutableBufferSequence,
+ detail::transfer_all_t, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))>(
+ d, offset, buffers, transfer_all(), init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 #if !defined(BOOST_NO_IOSTREAM)
@@ -687,24 +705,13 @@
     boost_asio_handler_invoke_helpers::invoke(
         function, this_handler->handler_);
   }
-
- template <typename AsyncRandomAccessReadDevice, typename Allocator,
- typename CompletionCondition, typename ReadHandler>
- inline read_at_streambuf_op<AsyncRandomAccessReadDevice,
- Allocator, CompletionCondition, ReadHandler>
- make_read_at_streambuf_op(AsyncRandomAccessReadDevice& d,
- boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
- CompletionCondition completion_condition, ReadHandler handler)
- {
- return read_at_streambuf_op<AsyncRandomAccessReadDevice,
- Allocator, CompletionCondition, ReadHandler>(
- d, offset, b, completion_condition, handler);
- }
 } // namespace detail
 
 template <typename AsyncRandomAccessReadDevice, typename Allocator,
     typename CompletionCondition, typename ReadHandler>
-inline void async_read_at(AsyncRandomAccessReadDevice& d,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_at(AsyncRandomAccessReadDevice& d,
     boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
@@ -713,15 +720,24 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_at_streambuf_op(
- d, offset, b, completion_condition,
- BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
+ CompletionCondition, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))>(
+ d, offset, b, completion_condition, init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 template <typename AsyncRandomAccessReadDevice, typename Allocator,
     typename ReadHandler>
-inline void async_read_at(AsyncRandomAccessReadDevice& d,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_at(AsyncRandomAccessReadDevice& d,
     boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
 {
@@ -729,10 +745,17 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_at_streambuf_op(
- d, offset, b, transfer_all(),
- BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_at_streambuf_op<AsyncRandomAccessReadDevice, Allocator,
+ detail::transfer_all_t, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))>(
+ d, offset, b, transfer_all(), init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 #endif // !defined(BOOST_NO_IOSTREAM)

Modified: trunk/boost/asio/impl/read_until.hpp
==============================================================================
--- trunk/boost/asio/impl/read_until.hpp (original)
+++ trunk/boost/asio/impl/read_until.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -471,20 +471,12 @@
     boost_asio_handler_invoke_helpers::invoke(
         function, this_handler->handler_);
   }
-
- template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
- inline read_until_delim_op<AsyncReadStream, Allocator, ReadHandler>
- make_read_until_delim_op(AsyncReadStream& s,
- boost::asio::basic_streambuf<Allocator>& b,
- char delim, ReadHandler handler)
- {
- return read_until_delim_op<AsyncReadStream, Allocator, ReadHandler>(
- s, b, delim, handler);
- }
 } // namespace detail
 
 template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-void async_read_until(AsyncReadStream& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_until(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b, char delim,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
 {
@@ -492,9 +484,17 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_until_delim_op(
- s, b, delim, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_until_delim_op<AsyncReadStream,
+ Allocator, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))>(
+ s, b, delim, init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 namespace detail
@@ -660,20 +660,12 @@
     boost_asio_handler_invoke_helpers::invoke(
         function, this_handler->handler_);
   }
-
- template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
- inline read_until_delim_string_op<AsyncReadStream, Allocator, ReadHandler>
- make_read_until_delim_string_op(AsyncReadStream& s,
- boost::asio::basic_streambuf<Allocator>& b,
- const std::string& delim, ReadHandler handler)
- {
- return read_until_delim_string_op<AsyncReadStream, Allocator, ReadHandler>(
- s, b, delim, handler);
- }
 } // namespace detail
 
 template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-void async_read_until(AsyncReadStream& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_until(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b, const std::string& delim,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
 {
@@ -681,9 +673,17 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_until_delim_string_op(
- s, b, delim, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_until_delim_string_op<AsyncReadStream,
+ Allocator, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))>(
+ s, b, delim, init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 namespace detail
@@ -855,21 +855,12 @@
     boost_asio_handler_invoke_helpers::invoke(
         function, this_handler->handler_);
   }
-
- template <typename AsyncReadStream, typename Allocator,
- typename RegEx, typename ReadHandler>
- inline read_until_expr_op<AsyncReadStream, Allocator, RegEx, ReadHandler>
- make_read_until_expr_op(AsyncReadStream& s,
- boost::asio::basic_streambuf<Allocator>& b,
- const RegEx& expr, ReadHandler handler)
- {
- return read_until_expr_op<AsyncReadStream, Allocator, RegEx, ReadHandler>(
- s, b, expr, handler);
- }
 } // namespace detail
 
 template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-void async_read_until(AsyncReadStream& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_until(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b, const boost::regex& expr,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
 {
@@ -877,9 +868,17 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_until_expr_op(
- s, b, expr, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_until_expr_op<AsyncReadStream, Allocator,
+ boost::regex, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))>(
+ s, b, expr, init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 namespace detail
@@ -1047,24 +1046,13 @@
     boost_asio_handler_invoke_helpers::invoke(
         function, this_handler->handler_);
   }
-
- template <typename AsyncReadStream, typename Allocator,
- typename MatchCondition, typename ReadHandler>
- inline read_until_match_op<AsyncReadStream, Allocator,
- MatchCondition, ReadHandler>
- make_read_until_match_op(AsyncReadStream& s,
- boost::asio::basic_streambuf<Allocator>& b,
- MatchCondition match_condition, ReadHandler handler)
- {
- return read_until_match_op<AsyncReadStream,
- Allocator, MatchCondition, ReadHandler>(
- s, b, match_condition, handler);
- }
 } // namespace detail
 
 template <typename AsyncReadStream, typename Allocator,
     typename MatchCondition, typename ReadHandler>
-void async_read_until(AsyncReadStream& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_until(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b,
     MatchCondition match_condition, BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
     typename boost::enable_if<is_match_condition<MatchCondition> >::type*)
@@ -1073,9 +1061,17 @@
   // not meet the documented type requirements for a ReadHandler.
   BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::make_read_until_match_op(
- s, b, match_condition, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::read_until_match_op<AsyncReadStream, Allocator,
+ MatchCondition, BOOST_ASIO_HANDLER_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))>(
+ s, b, match_condition, init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 } // namespace asio

Modified: trunk/boost/asio/impl/write.hpp
==============================================================================
--- trunk/boost/asio/impl/write.hpp (original)
+++ trunk/boost/asio/impl/write.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -544,22 +544,13 @@
     boost_asio_handler_invoke_helpers::invoke(
         function, this_handler->handler_);
   }
-
- template <typename AsyncWriteStream, typename ConstBufferSequence,
- typename CompletionCondition, typename WriteHandler>
- inline write_op<AsyncWriteStream, ConstBufferSequence,
- CompletionCondition, WriteHandler>
- make_write_op(AsyncWriteStream& s, const ConstBufferSequence& buffers,
- CompletionCondition completion_condition, WriteHandler handler)
- {
- return write_op<AsyncWriteStream, ConstBufferSequence, CompletionCondition,
- WriteHandler>(s, buffers, completion_condition, handler);
- }
 } // namespace detail
 
 template <typename AsyncWriteStream, typename ConstBufferSequence,
   typename CompletionCondition, typename WriteHandler>
-inline void async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
 {
@@ -567,24 +558,41 @@
   // not meet the documented type requirements for a WriteHandler.
   BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- detail::make_write_op(
- s, buffers, completion_condition,
- BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ detail::write_op<AsyncWriteStream, ConstBufferSequence,
+ CompletionCondition, BOOST_ASIO_HANDLER_TYPE(
+ WriteHandler, void (boost::system::error_code, std::size_t))>(
+ s, buffers, completion_condition, init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 template <typename AsyncWriteStream, typename ConstBufferSequence,
     typename WriteHandler>
-inline void async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
 {
   // If you get an error on the following line it means that your handler does
   // not meet the documented type requirements for a WriteHandler.
   BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- detail::make_write_op(
- s, buffers, transfer_all(), BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ detail::write_op<AsyncWriteStream, ConstBufferSequence,
+ detail::transfer_all_t, BOOST_ASIO_HANDLER_TYPE(
+ WriteHandler, void (boost::system::error_code, std::size_t))>(
+ s, buffers, transfer_all(), init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 #if !defined(BOOST_NO_IOSTREAM)
@@ -659,19 +667,13 @@
     boost_asio_handler_invoke_helpers::invoke(
         function, this_handler->handler_);
   }
-
- template <typename Allocator, typename WriteHandler>
- inline write_streambuf_handler<Allocator, WriteHandler>
- make_write_streambuf_handler(
- boost::asio::basic_streambuf<Allocator>& b, WriteHandler handler)
- {
- return write_streambuf_handler<Allocator, WriteHandler>(b, handler);
- }
 } // namespace detail
 
 template <typename AsyncWriteStream, typename Allocator,
     typename CompletionCondition, typename WriteHandler>
-inline void async_write(AsyncWriteStream& s,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write(AsyncWriteStream& s,
     boost::asio::basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
@@ -680,13 +682,22 @@
   // not meet the documented type requirements for a WriteHandler.
   BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
   async_write(s, b.data(), completion_condition,
- detail::make_write_streambuf_handler(
- b, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)));
+ detail::write_streambuf_handler<Allocator, BOOST_ASIO_HANDLER_TYPE(
+ WriteHandler, void (boost::system::error_code, std::size_t))>(
+ b, init.handler));
+
+ return init.result.get();
 }
 
 template <typename AsyncWriteStream, typename Allocator, typename WriteHandler>
-inline void async_write(AsyncWriteStream& s,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write(AsyncWriteStream& s,
     boost::asio::basic_streambuf<Allocator>& b,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
 {
@@ -694,9 +705,16 @@
   // not meet the documented type requirements for a WriteHandler.
   BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
   async_write(s, b.data(), transfer_all(),
- detail::make_write_streambuf_handler(
- b, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)));
+ detail::write_streambuf_handler<Allocator, BOOST_ASIO_HANDLER_TYPE(
+ WriteHandler, void (boost::system::error_code, std::size_t))>(
+ b, init.handler));
+
+ return init.result.get();
 }
 
 #endif // !defined(BOOST_NO_IOSTREAM)

Modified: trunk/boost/asio/impl/write_at.hpp
==============================================================================
--- trunk/boost/asio/impl/write_at.hpp (original)
+++ trunk/boost/asio/impl/write_at.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -596,7 +596,9 @@
 
 template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
     typename CompletionCondition, typename WriteHandler>
-inline void async_write_at(AsyncRandomAccessWriteDevice& d,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write_at(AsyncRandomAccessWriteDevice& d,
     boost::uint64_t offset, const ConstBufferSequence& buffers,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
@@ -605,15 +607,24 @@
   // not meet the documented type requirements for a WriteHandler.
   BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- detail::make_write_at_op(
- d, offset, buffers, completion_condition,
- BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ detail::write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
+ CompletionCondition, BOOST_ASIO_HANDLER_TYPE(
+ WriteHandler, void (boost::system::error_code, std::size_t))>(
+ d, offset, buffers, completion_condition, init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
     typename WriteHandler>
-inline void async_write_at(AsyncRandomAccessWriteDevice& d,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write_at(AsyncRandomAccessWriteDevice& d,
     boost::uint64_t offset, const ConstBufferSequence& buffers,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
 {
@@ -621,10 +632,17 @@
   // not meet the documented type requirements for a WriteHandler.
   BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- detail::make_write_at_op(
- d, offset, buffers, transfer_all(),
- BOOST_ASIO_MOVE_CAST(WriteHandler)(handler))(
- boost::system::error_code(), 0, 1);
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ detail::write_at_op<AsyncRandomAccessWriteDevice, ConstBufferSequence,
+ detail::transfer_all_t, BOOST_ASIO_HANDLER_TYPE(
+ WriteHandler, void (boost::system::error_code, std::size_t))>(
+ d, offset, buffers, transfer_all(), init.handler)(
+ boost::system::error_code(), 0, 1);
+
+ return init.result.get();
 }
 
 #if !defined(BOOST_NO_IOSTREAM)
@@ -712,7 +730,9 @@
 
 template <typename AsyncRandomAccessWriteDevice, typename Allocator,
     typename CompletionCondition, typename WriteHandler>
-inline void async_write_at(AsyncRandomAccessWriteDevice& d,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write_at(AsyncRandomAccessWriteDevice& d,
     boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
@@ -721,14 +741,23 @@
   // not meet the documented type requirements for a WriteHandler.
   BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
   async_write_at(d, offset, b.data(), completion_condition,
- detail::make_write_at_streambuf_op(
- b, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)));
+ detail::write_at_streambuf_op<Allocator, BOOST_ASIO_HANDLER_TYPE(
+ WriteHandler, void (boost::system::error_code, std::size_t))>(
+ b, init.handler));
+
+ return init.result.get();
 }
 
 template <typename AsyncRandomAccessWriteDevice, typename Allocator,
     typename WriteHandler>
-inline void async_write_at(AsyncRandomAccessWriteDevice& d,
+inline BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write_at(AsyncRandomAccessWriteDevice& d,
     boost::uint64_t offset, boost::asio::basic_streambuf<Allocator>& b,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
 {
@@ -736,9 +765,16 @@
   // not meet the documented type requirements for a WriteHandler.
   BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
+ BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
   async_write_at(d, offset, b.data(), transfer_all(),
- detail::make_write_at_streambuf_op(
- b, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler)));
+ detail::write_at_streambuf_op<Allocator, BOOST_ASIO_HANDLER_TYPE(
+ WriteHandler, void (boost::system::error_code, std::size_t))>(
+ b, init.handler));
+
+ return init.result.get();
 }
 
 #endif // !defined(BOOST_NO_IOSTREAM)

Modified: trunk/boost/asio/io_service.hpp
==============================================================================
--- trunk/boost/asio/io_service.hpp (original)
+++ trunk/boost/asio/io_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -19,6 +19,7 @@
 #include <cstddef>
 #include <stdexcept>
 #include <typeinfo>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/detail/noncopyable.hpp>
 #include <boost/asio/detail/service_registry_fwd.hpp>
 #include <boost/asio/detail/wrapped_handler.hpp>
@@ -441,7 +442,8 @@
    * throws an exception.
    */
   template <typename CompletionHandler>
- void dispatch(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler);
+ BOOST_ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
+ dispatch(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler);
 
   /// Request the io_service to invoke the given handler and return immediately.
   /**
@@ -466,7 +468,8 @@
    * throws an exception.
    */
   template <typename CompletionHandler>
- void post(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler);
+ BOOST_ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
+ post(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler);
 
   /// Create a new handler that automatically dispatches the wrapped handler
   /// on the io_service.

Modified: trunk/boost/asio/ip/basic_resolver.hpp
==============================================================================
--- trunk/boost/asio/ip/basic_resolver.hpp (original)
+++ trunk/boost/asio/ip/basic_resolver.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -153,7 +153,9 @@
    * the handler.
    */
   template <typename ResolveHandler>
- void async_resolve(const query& q,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ResolveHandler,
+ void (boost::system::error_code, iterator))
+ async_resolve(const query& q,
       BOOST_ASIO_MOVE_ARG(ResolveHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
@@ -244,7 +246,9 @@
    * the handler.
    */
   template <typename ResolveHandler>
- void async_resolve(const endpoint_type& e,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ResolveHandler,
+ void (boost::system::error_code, iterator))
+ async_resolve(const endpoint_type& e,
       BOOST_ASIO_MOVE_ARG(ResolveHandler) handler)
   {
     // If you get an error on the following line it means that your handler does

Modified: trunk/boost/asio/ip/resolver_service.hpp
==============================================================================
--- trunk/boost/asio/ip/resolver_service.hpp (original)
+++ trunk/boost/asio/ip/resolver_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -16,6 +16,7 @@
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
 #include <boost/asio/detail/config.hpp>
+#include <boost/asio/async_result.hpp>
 #include <boost/system/error_code.hpp>
 #include <boost/asio/detail/resolver_service.hpp>
 #include <boost/asio/io_service.hpp>
@@ -104,11 +105,18 @@
 
   /// Asynchronously resolve a query to a list of entries.
   template <typename ResolveHandler>
- void async_resolve(implementation_type& impl, const query_type& query,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ResolveHandler,
+ void (boost::system::error_code, iterator_type))
+ async_resolve(implementation_type& impl, const query_type& query,
       BOOST_ASIO_MOVE_ARG(ResolveHandler) handler)
   {
- service_impl_.async_resolve(impl, query,
+ boost::asio::detail::async_result_init<
+ ResolveHandler, void (boost::system::error_code, iterator_type)> init(
         BOOST_ASIO_MOVE_CAST(ResolveHandler)(handler));
+
+ service_impl_.async_resolve(impl, query, init.handler);
+
+ return init.result.get();
   }
 
   /// Resolve an endpoint to a list of entries.
@@ -120,11 +128,18 @@
 
   /// Asynchronously resolve an endpoint to a list of entries.
   template <typename ResolveHandler>
- void async_resolve(implementation_type& impl, const endpoint_type& endpoint,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ResolveHandler,
+ void (boost::system::error_code, iterator_type))
+ async_resolve(implementation_type& impl, const endpoint_type& endpoint,
       BOOST_ASIO_MOVE_ARG(ResolveHandler) handler)
   {
- return service_impl_.async_resolve(impl, endpoint,
+ boost::asio::detail::async_result_init<
+ ResolveHandler, void (boost::system::error_code, iterator_type)> init(
         BOOST_ASIO_MOVE_CAST(ResolveHandler)(handler));
+
+ service_impl_.async_resolve(impl, endpoint, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/posix/basic_stream_descriptor.hpp
==============================================================================
--- trunk/boost/asio/posix/basic_stream_descriptor.hpp (original)
+++ trunk/boost/asio/posix/basic_stream_descriptor.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -225,14 +225,16 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some(const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_write_some(this->get_implementation(),
+ return this->get_service().async_write_some(this->get_implementation(),
         buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -336,14 +338,16 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some(const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_read_some(this->get_implementation(),
+ return this->get_service().async_read_some(this->get_implementation(),
         buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };

Modified: trunk/boost/asio/posix/stream_descriptor_service.hpp
==============================================================================
--- trunk/boost/asio/posix/stream_descriptor_service.hpp (original)
+++ trunk/boost/asio/posix/stream_descriptor_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -21,6 +21,7 @@
   || defined(GENERATING_DOCUMENTATION)
 
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/detail/reactive_descriptor_service.hpp>
@@ -198,12 +199,19 @@
 
   /// Start an asynchronous write.
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some(implementation_type& impl,
       const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
- service_impl_.async_write_some(impl, buffers,
+ boost::asio::detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ service_impl_.async_write_some(impl, buffers, init.handler);
+
+ return init.result.get();
   }
 
   /// Read some data from the stream.
@@ -216,12 +224,19 @@
 
   /// Start an asynchronous read.
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some(implementation_type& impl,
       const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
- service_impl_.async_read_some(impl, buffers,
+ boost::asio::detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ service_impl_.async_read_some(impl, buffers, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/raw_socket_service.hpp
==============================================================================
--- trunk/boost/asio/raw_socket_service.hpp (original)
+++ trunk/boost/asio/raw_socket_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
 
@@ -200,12 +201,19 @@
 
   /// Start an asynchronous connect.
   template <typename ConnectHandler>
- void async_connect(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ConnectHandler,
+ void (boost::system::error_code))
+ async_connect(implementation_type& impl,
       const endpoint_type& peer_endpoint,
       BOOST_ASIO_MOVE_ARG(ConnectHandler) handler)
   {
- service_impl_.async_connect(impl, peer_endpoint,
+ detail::async_result_init<
+ ConnectHandler, void (boost::system::error_code)> init(
         BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
+
+ service_impl_.async_connect(impl, peer_endpoint, init.handler);
+
+ return init.result.get();
   }
 
   /// Set a socket option.
@@ -290,12 +298,19 @@
 
   /// Start an asynchronous send.
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send(implementation_type& impl, const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send(implementation_type& impl, const ConstBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
- service_impl_.async_send(impl, buffers, flags,
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ service_impl_.async_send(impl, buffers, flags, init.handler);
+
+ return init.result.get();
   }
 
   /// Send raw data to the specified endpoint.
@@ -309,13 +324,21 @@
 
   /// Start an asynchronous send.
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send_to(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send_to(implementation_type& impl,
       const ConstBufferSequence& buffers, const endpoint_type& destination,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
- service_impl_.async_send_to(impl, buffers, destination, flags,
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ service_impl_.async_send_to(impl, buffers,
+ destination, flags, init.handler);
+
+ return init.result.get();
   }
 
   /// Receive some data from the peer.
@@ -329,13 +352,20 @@
 
   /// Start an asynchronous receive.
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(implementation_type& impl,
       const MutableBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
- service_impl_.async_receive(impl, buffers, flags,
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ service_impl_.async_receive(impl, buffers, flags, init.handler);
+
+ return init.result.get();
   }
 
   /// Receive raw data with the endpoint of the sender.
@@ -350,13 +380,21 @@
 
   /// Start an asynchronous receive that will get the endpoint of the sender.
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive_from(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive_from(implementation_type& impl,
       const MutableBufferSequence& buffers, endpoint_type& sender_endpoint,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
- service_impl_.async_receive_from(impl, buffers, sender_endpoint, flags,
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ service_impl_.async_receive_from(impl, buffers,
+ sender_endpoint, flags, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/read.hpp
==============================================================================
--- trunk/boost/asio/read.hpp (original)
+++ trunk/boost/asio/read.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/basic_streambuf_fwd.hpp>
 #include <boost/asio/error.hpp>
 
@@ -422,7 +423,9 @@
  */
 template <typename AsyncReadStream, typename MutableBufferSequence,
     typename ReadHandler>
-void async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
 
 /// Start an asynchronous operation to read a certain amount of data from a
@@ -490,7 +493,9 @@
  */
 template <typename AsyncReadStream, typename MutableBufferSequence,
     typename CompletionCondition, typename ReadHandler>
-void async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read(AsyncReadStream& s, const MutableBufferSequence& buffers,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
 
@@ -545,7 +550,9 @@
  * handler); @endcode
  */
 template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-void async_read(AsyncReadStream& s, basic_streambuf<Allocator>& b,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read(AsyncReadStream& s, basic_streambuf<Allocator>& b,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
 
 /// Start an asynchronous operation to read a certain amount of data from a
@@ -606,7 +613,9 @@
  */
 template <typename AsyncReadStream, typename Allocator,
     typename CompletionCondition, typename ReadHandler>
-void async_read(AsyncReadStream& s, basic_streambuf<Allocator>& b,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read(AsyncReadStream& s, basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
 

Modified: trunk/boost/asio/read_at.hpp
==============================================================================
--- trunk/boost/asio/read_at.hpp (original)
+++ trunk/boost/asio/read_at.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -18,6 +18,7 @@
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
 #include <boost/cstdint.hpp>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/basic_streambuf_fwd.hpp>
 #include <boost/asio/error.hpp>
 
@@ -455,7 +456,9 @@
  */
 template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
     typename ReadHandler>
-void async_read_at(AsyncRandomAccessReadDevice& d, boost::uint64_t offset,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_at(AsyncRandomAccessReadDevice& d, boost::uint64_t offset,
     const MutableBufferSequence& buffers,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
 
@@ -526,7 +529,9 @@
  */
 template <typename AsyncRandomAccessReadDevice, typename MutableBufferSequence,
     typename CompletionCondition, typename ReadHandler>
-void async_read_at(AsyncRandomAccessReadDevice& d,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_at(AsyncRandomAccessReadDevice& d,
     boost::uint64_t offset, const MutableBufferSequence& buffers,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
@@ -580,7 +585,9 @@
  */
 template <typename AsyncRandomAccessReadDevice, typename Allocator,
     typename ReadHandler>
-void async_read_at(AsyncRandomAccessReadDevice& d, boost::uint64_t offset,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_at(AsyncRandomAccessReadDevice& d, boost::uint64_t offset,
     basic_streambuf<Allocator>& b, BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
 
 /// Start an asynchronous operation to read a certain amount of data at the
@@ -638,7 +645,9 @@
  */
 template <typename AsyncRandomAccessReadDevice, typename Allocator,
     typename CompletionCondition, typename ReadHandler>
-void async_read_at(AsyncRandomAccessReadDevice& d,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_at(AsyncRandomAccessReadDevice& d,
     boost::uint64_t offset, basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler);

Modified: trunk/boost/asio/read_until.hpp
==============================================================================
--- trunk/boost/asio/read_until.hpp (original)
+++ trunk/boost/asio/read_until.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -25,6 +25,7 @@
 #include <boost/utility/enable_if.hpp>
 #include <boost/detail/workaround.hpp>
 #include <string>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/basic_streambuf.hpp>
 #include <boost/asio/detail/regex_fwd.hpp>
 #include <boost/asio/error.hpp>
@@ -588,7 +589,9 @@
  * @c async_read_until operation.
  */
 template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-void async_read_until(AsyncReadStream& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_until(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b,
     char delim, BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
 
@@ -671,7 +674,9 @@
  * @c async_read_until operation.
  */
 template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-void async_read_until(AsyncReadStream& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_until(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b, const std::string& delim,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
 
@@ -758,7 +763,9 @@
  * @c async_read_until operation.
  */
 template <typename AsyncReadStream, typename Allocator, typename ReadHandler>
-void async_read_until(AsyncReadStream& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_until(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b, const boost::regex& expr,
     BOOST_ASIO_MOVE_ARG(ReadHandler) handler);
 
@@ -887,7 +894,9 @@
  */
 template <typename AsyncReadStream, typename Allocator,
     typename MatchCondition, typename ReadHandler>
-void async_read_until(AsyncReadStream& s,
+BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+async_read_until(AsyncReadStream& s,
     boost::asio::basic_streambuf<Allocator>& b,
     MatchCondition match_condition, BOOST_ASIO_MOVE_ARG(ReadHandler) handler,
     typename boost::enable_if<is_match_condition<MatchCondition> >::type* = 0);

Modified: trunk/boost/asio/seq_packet_socket_service.hpp
==============================================================================
--- trunk/boost/asio/seq_packet_socket_service.hpp (original)
+++ trunk/boost/asio/seq_packet_socket_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
 
@@ -202,12 +203,19 @@
 
   /// Start an asynchronous connect.
   template <typename ConnectHandler>
- void async_connect(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ConnectHandler,
+ void (boost::system::error_code))
+ async_connect(implementation_type& impl,
       const endpoint_type& peer_endpoint,
       BOOST_ASIO_MOVE_ARG(ConnectHandler) handler)
   {
- service_impl_.async_connect(impl, peer_endpoint,
+ detail::async_result_init<
+ ConnectHandler, void (boost::system::error_code)> init(
         BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
+
+ service_impl_.async_connect(impl, peer_endpoint, init.handler);
+
+ return init.result.get();
   }
 
   /// Set a socket option.

Modified: trunk/boost/asio/serial_port_service.hpp
==============================================================================
--- trunk/boost/asio/serial_port_service.hpp (original)
+++ trunk/boost/asio/serial_port_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -22,6 +22,7 @@
 
 #include <cstddef>
 #include <string>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/detail/reactive_serial_port_service.hpp>
 #include <boost/asio/detail/win_iocp_serial_port_service.hpp>
 #include <boost/asio/error.hpp>
@@ -192,12 +193,19 @@
 
   /// Start an asynchronous write.
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some(implementation_type& impl,
       const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
- service_impl_.async_write_some(impl, buffers,
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ service_impl_.async_write_some(impl, buffers, init.handler);
+
+ return init.result.get();
   }
 
   /// Read some data from the stream.
@@ -210,12 +218,19 @@
 
   /// Start an asynchronous read.
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some(implementation_type& impl,
       const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
- service_impl_.async_read_some(impl, buffers,
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ service_impl_.async_read_some(impl, buffers, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/signal_set_service.hpp
==============================================================================
--- trunk/boost/asio/signal_set_service.hpp (original)
+++ trunk/boost/asio/signal_set_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -16,6 +16,7 @@
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
 #include <boost/asio/detail/config.hpp>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/detail/signal_set_service.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
@@ -96,11 +97,18 @@
 
   // Start an asynchronous operation to wait for a signal to be delivered.
   template <typename SignalHandler>
- void async_wait(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(SignalHandler,
+ void (boost::system::error_code, int))
+ async_wait(implementation_type& impl,
       BOOST_ASIO_MOVE_ARG(SignalHandler) handler)
   {
- service_impl_.async_wait(impl,
+ detail::async_result_init<
+ SignalHandler, void (boost::system::error_code, int)> init(
         BOOST_ASIO_MOVE_CAST(SignalHandler)(handler));
+
+ service_impl_.async_wait(impl, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/socket_acceptor_service.hpp
==============================================================================
--- trunk/boost/asio/socket_acceptor_service.hpp (original)
+++ trunk/boost/asio/socket_acceptor_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -249,13 +249,20 @@
 
   /// Start an asynchronous accept.
   template <typename SocketService, typename AcceptHandler>
- void async_accept(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(AcceptHandler,
+ void (boost::system::error_code))
+ async_accept(implementation_type& impl,
       basic_socket<protocol_type, SocketService>& peer,
       endpoint_type* peer_endpoint,
       BOOST_ASIO_MOVE_ARG(AcceptHandler) handler)
   {
- service_impl_.async_accept(impl, peer, peer_endpoint,
+ detail::async_result_init<
+ AcceptHandler, void (boost::system::error_code)> init(
         BOOST_ASIO_MOVE_CAST(AcceptHandler)(handler));
+
+ service_impl_.async_accept(impl, peer, peer_endpoint, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/ssl/detail/io.hpp
==============================================================================
--- trunk/boost/asio/ssl/detail/io.hpp (original)
+++ trunk/boost/asio/ssl/detail/io.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -317,7 +317,7 @@
 
 template <typename Stream, typename Operation, typename Handler>
 inline void async_io(Stream& next_layer, stream_core& core,
- const Operation& op, Handler handler)
+ const Operation& op, Handler& handler)
 {
   io_op<Stream, Operation, Handler>(
     next_layer, core, op, handler)(

Modified: trunk/boost/asio/ssl/stream.hpp
==============================================================================
--- trunk/boost/asio/ssl/stream.hpp (original)
+++ trunk/boost/asio/ssl/stream.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -20,6 +20,7 @@
 #if defined(BOOST_ASIO_ENABLE_OLD_SSL)
 # include <boost/asio/ssl/old/stream.hpp>
 #else // defined(BOOST_ASIO_ENABLE_OLD_SSL)
+# include <boost/asio/async_result.hpp>
 # include <boost/asio/detail/buffer_sequence_adapter.hpp>
 # include <boost/asio/detail/handler_type_requirements.hpp>
 # include <boost/asio/detail/noncopyable.hpp>
@@ -359,15 +360,23 @@
    * ); @endcode
    */
   template <typename HandshakeHandler>
- void async_handshake(handshake_type type,
+ BOOST_ASIO_INITFN_RESULT_TYPE(HandshakeHandler,
+ void (boost::system::error_code))
+ async_handshake(handshake_type type,
       BOOST_ASIO_MOVE_ARG(HandshakeHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a HandshakeHandler.
     BOOST_ASIO_HANDSHAKE_HANDLER_CHECK(HandshakeHandler, handler) type_check;
 
- detail::async_io(next_layer_, core_, detail::handshake_op(type),
+ boost::asio::detail::async_result_init<
+ HandshakeHandler, void (boost::system::error_code)> init(
         BOOST_ASIO_MOVE_CAST(HandshakeHandler)(handler));
+
+ detail::async_io(next_layer_, core_,
+ detail::handshake_op(type), init.handler);
+
+ return init.result.get();
   }
 
   /// Shut down SSL on the stream.
@@ -410,14 +419,21 @@
    * ); @endcode
    */
   template <typename ShutdownHandler>
- void async_shutdown(BOOST_ASIO_MOVE_ARG(ShutdownHandler) handler)
+ BOOST_ASIO_INITFN_RESULT_TYPE(ShutdownHandler,
+ void (boost::system::error_code))
+ async_shutdown(BOOST_ASIO_MOVE_ARG(ShutdownHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a ShutdownHandler.
     BOOST_ASIO_SHUTDOWN_HANDLER_CHECK(ShutdownHandler, handler) type_check;
 
- detail::async_io(next_layer_, core_, detail::shutdown_op(),
+ boost::asio::detail::async_result_init<
+ ShutdownHandler, void (boost::system::error_code)> init(
         BOOST_ASIO_MOVE_CAST(ShutdownHandler)(handler));
+
+ detail::async_io(next_layer_, core_, detail::shutdown_op(), init.handler);
+
+ return init.result.get();
   }
 
   /// Write some data to the stream.
@@ -492,16 +508,23 @@
    * ensure that all data is written before the blocking operation completes.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some(const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- detail::async_io(next_layer_, core_,
- detail::write_op<ConstBufferSequence>(buffers),
+ boost::asio::detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ detail::async_io(next_layer_, core_,
+ detail::write_op<ConstBufferSequence>(buffers), init.handler);
+
+ return init.result.get();
   }
 
   /// Read some data from the stream.
@@ -577,16 +600,23 @@
    * operation completes.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some(const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- detail::async_io(next_layer_, core_,
- detail::read_op<MutableBufferSequence>(buffers),
+ boost::asio::detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ detail::async_io(next_layer_, core_,
+ detail::read_op<MutableBufferSequence>(buffers), init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/strand.hpp
==============================================================================
--- trunk/boost/asio/strand.hpp (original)
+++ trunk/boost/asio/strand.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -16,6 +16,7 @@
 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
 
 #include <boost/asio/detail/config.hpp>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/detail/handler_type_requirements.hpp>
 #include <boost/asio/detail/strand_service.hpp>
 #include <boost/asio/detail/wrapped_handler.hpp>
@@ -140,13 +141,20 @@
    * @code void handler(); @endcode
    */
   template <typename CompletionHandler>
- void dispatch(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
+ BOOST_ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
+ dispatch(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a CompletionHandler.
     BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
 
- service_.dispatch(impl_, BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+ detail::async_result_init<
+ CompletionHandler, void ()> init(
+ BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+
+ service_.dispatch(impl_, init.handler);
+
+ return init.result.get();
   }
 
   /// Request the strand to invoke the given handler and return
@@ -166,13 +174,20 @@
    * @code void handler(); @endcode
    */
   template <typename CompletionHandler>
- void post(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
+ BOOST_ASIO_INITFN_RESULT_TYPE(CompletionHandler, void ())
+ post(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a CompletionHandler.
     BOOST_ASIO_COMPLETION_HANDLER_CHECK(CompletionHandler, handler) type_check;
 
- service_.post(impl_, BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+ detail::async_result_init<
+ CompletionHandler, void ()> init(
+ BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler));
+
+ service_.post(impl_, init.handler);
+
+ return init.result.get();
   }
 
   /// Create a new handler that automatically dispatches the wrapped handler

Modified: trunk/boost/asio/stream_socket_service.hpp
==============================================================================
--- trunk/boost/asio/stream_socket_service.hpp (original)
+++ trunk/boost/asio/stream_socket_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
 
@@ -200,12 +201,19 @@
 
   /// Start an asynchronous connect.
   template <typename ConnectHandler>
- void async_connect(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ConnectHandler,
+ void (boost::system::error_code))
+ async_connect(implementation_type& impl,
       const endpoint_type& peer_endpoint,
       BOOST_ASIO_MOVE_ARG(ConnectHandler) handler)
   {
- service_impl_.async_connect(impl, peer_endpoint,
+ detail::async_result_init<
+ ConnectHandler, void (boost::system::error_code)> init(
         BOOST_ASIO_MOVE_CAST(ConnectHandler)(handler));
+
+ service_impl_.async_connect(impl, peer_endpoint, init.handler);
+
+ return init.result.get();
   }
 
   /// Set a socket option.
@@ -290,13 +298,20 @@
 
   /// Start an asynchronous send.
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_send(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_send(implementation_type& impl,
       const ConstBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
- service_impl_.async_send(impl, buffers, flags,
+ detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ service_impl_.async_send(impl, buffers, flags, init.handler);
+
+ return init.result.get();
   }
 
   /// Receive some data from the peer.
@@ -310,13 +325,20 @@
 
   /// Start an asynchronous receive.
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_receive(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_receive(implementation_type& impl,
       const MutableBufferSequence& buffers,
       socket_base::message_flags flags,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
- service_impl_.async_receive(impl, buffers, flags,
+ detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ service_impl_.async_receive(impl, buffers, flags, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/waitable_timer_service.hpp
==============================================================================
--- trunk/boost/asio/waitable_timer_service.hpp (original)
+++ trunk/boost/asio/waitable_timer_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/detail/chrono_time_traits.hpp>
 #include <boost/asio/detail/deadline_timer_service.hpp>
 #include <boost/asio/io_service.hpp>
@@ -136,10 +137,18 @@
 
   // Start an asynchronous wait on the timer.
   template <typename WaitHandler>
- void async_wait(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
+ void (boost::system::error_code))
+ async_wait(implementation_type& impl,
       BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
   {
- service_impl_.async_wait(impl, BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
+ detail::async_result_init<
+ WaitHandler, void (boost::system::error_code)> init(
+ BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
+
+ service_impl_.async_wait(impl, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/windows/basic_object_handle.hpp
==============================================================================
--- trunk/boost/asio/windows/basic_object_handle.hpp (original)
+++ trunk/boost/asio/windows/basic_object_handle.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -159,9 +159,12 @@
    * boost::asio::io_service::post().
    */
   template <typename WaitHandler>
- void async_wait(WaitHandler handler)
+ BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
+ void (boost::system::error_code))
+ async_wait(BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
   {
- this->get_service().async_wait(this->get_implementation(), handler);
+ return this->get_service().async_wait(this->get_implementation(),
+ BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
   }
 };
 

Modified: trunk/boost/asio/windows/basic_random_access_handle.hpp
==============================================================================
--- trunk/boost/asio/windows/basic_random_access_handle.hpp (original)
+++ trunk/boost/asio/windows/basic_random_access_handle.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -230,7 +230,9 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some_at(boost::uint64_t offset,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some_at(boost::uint64_t offset,
       const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
@@ -238,7 +240,7 @@
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_write_some_at(this->get_implementation(),
+ return this->get_service().async_write_some_at(this->get_implementation(),
         offset, buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -349,7 +351,9 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some_at(boost::uint64_t offset,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some_at(boost::uint64_t offset,
       const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
@@ -357,7 +361,7 @@
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_read_some_at(this->get_implementation(),
+ return this->get_service().async_read_some_at(this->get_implementation(),
         offset, buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };

Modified: trunk/boost/asio/windows/basic_stream_handle.hpp
==============================================================================
--- trunk/boost/asio/windows/basic_stream_handle.hpp (original)
+++ trunk/boost/asio/windows/basic_stream_handle.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -222,14 +222,16 @@
    * std::vector.
    */
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some(const ConstBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some(const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a WriteHandler.
     BOOST_ASIO_WRITE_HANDLER_CHECK(WriteHandler, handler) type_check;
 
- this->get_service().async_write_some(this->get_implementation(),
+ return this->get_service().async_write_some(this->get_implementation(),
         buffers, BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
   }
 
@@ -333,14 +335,16 @@
    * std::vector.
    */
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some(const MutableBufferSequence& buffers,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some(const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
     // If you get an error on the following line it means that your handler does
     // not meet the documented type requirements for a ReadHandler.
     BOOST_ASIO_READ_HANDLER_CHECK(ReadHandler, handler) type_check;
 
- this->get_service().async_read_some(this->get_implementation(),
+ return this->get_service().async_read_some(this->get_implementation(),
         buffers, BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
   }
 };

Modified: trunk/boost/asio/windows/object_handle_service.hpp
==============================================================================
--- trunk/boost/asio/windows/object_handle_service.hpp (original)
+++ trunk/boost/asio/windows/object_handle_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -21,6 +21,7 @@
 #if defined(BOOST_ASIO_HAS_WINDOWS_OBJECT_HANDLE) \
   || defined(GENERATING_DOCUMENTATION)
 
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/detail/win_object_handle_service.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
@@ -141,10 +142,18 @@
 
   /// Start an asynchronous wait.
   template <typename WaitHandler>
- void async_wait(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WaitHandler,
+ void (boost::system::error_code))
+ async_wait(implementation_type& impl,
       BOOST_ASIO_MOVE_ARG(WaitHandler) handler)
   {
- service_impl_.async_wait(impl, BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
+ boost::asio::detail::async_result_init<
+ WaitHandler, void (boost::system::error_code)> init(
+ BOOST_ASIO_MOVE_CAST(WaitHandler)(handler));
+
+ service_impl_.async_wait(impl, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/windows/random_access_handle_service.hpp
==============================================================================
--- trunk/boost/asio/windows/random_access_handle_service.hpp (original)
+++ trunk/boost/asio/windows/random_access_handle_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -23,6 +23,7 @@
 #include <cstddef>
 #include <boost/config.hpp>
 #include <boost/cstdint.hpp>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/detail/win_iocp_handle_service.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
@@ -159,12 +160,19 @@
 
   /// Start an asynchronous write at the specified offset.
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some_at(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some_at(implementation_type& impl,
       boost::uint64_t offset, const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
- service_impl_.async_write_some_at(impl, offset, buffers,
+ boost::asio::detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ service_impl_.async_write_some_at(impl, offset, buffers, init.handler);
+
+ return init.result.get();
   }
 
   /// Read some data from the specified offset.
@@ -177,12 +185,19 @@
 
   /// Start an asynchronous read at the specified offset.
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some_at(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some_at(implementation_type& impl,
       boost::uint64_t offset, const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
- service_impl_.async_read_some_at(impl, offset, buffers,
+ boost::asio::detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ service_impl_.async_read_some_at(impl, offset, buffers, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/windows/stream_handle_service.hpp
==============================================================================
--- trunk/boost/asio/windows/stream_handle_service.hpp (original)
+++ trunk/boost/asio/windows/stream_handle_service.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -21,6 +21,7 @@
   || defined(GENERATING_DOCUMENTATION)
 
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/detail/win_iocp_handle_service.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/io_service.hpp>
@@ -156,12 +157,19 @@
 
   /// Start an asynchronous write.
   template <typename ConstBufferSequence, typename WriteHandler>
- void async_write_some(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+ async_write_some(implementation_type& impl,
       const ConstBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(WriteHandler) handler)
   {
- service_impl_.async_write_some(impl, buffers,
+ boost::asio::detail::async_result_init<
+ WriteHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(WriteHandler)(handler));
+
+ service_impl_.async_write_some(impl, buffers, init.handler);
+
+ return init.result.get();
   }
 
   /// Read some data from the stream.
@@ -174,12 +182,19 @@
 
   /// Start an asynchronous read.
   template <typename MutableBufferSequence, typename ReadHandler>
- void async_read_some(implementation_type& impl,
+ BOOST_ASIO_INITFN_RESULT_TYPE(ReadHandler,
+ void (boost::system::error_code, std::size_t))
+ async_read_some(implementation_type& impl,
       const MutableBufferSequence& buffers,
       BOOST_ASIO_MOVE_ARG(ReadHandler) handler)
   {
- service_impl_.async_read_some(impl, buffers,
+ boost::asio::detail::async_result_init<
+ ReadHandler, void (boost::system::error_code, std::size_t)> init(
         BOOST_ASIO_MOVE_CAST(ReadHandler)(handler));
+
+ service_impl_.async_read_some(impl, buffers, init.handler);
+
+ return init.result.get();
   }
 
 private:

Modified: trunk/boost/asio/write.hpp
==============================================================================
--- trunk/boost/asio/write.hpp (original)
+++ trunk/boost/asio/write.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/basic_streambuf_fwd.hpp>
 #include <boost/asio/error.hpp>
 
@@ -413,7 +414,9 @@
  */
 template <typename AsyncWriteStream, typename ConstBufferSequence,
     typename WriteHandler>
-void async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
+BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler);
 
 /// Start an asynchronous operation to write a certain amount of data to a
@@ -485,7 +488,9 @@
  */
 template <typename AsyncWriteStream, typename ConstBufferSequence,
     typename CompletionCondition, typename WriteHandler>
-void async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
+BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write(AsyncWriteStream& s, const ConstBufferSequence& buffers,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler);
 
@@ -533,7 +538,9 @@
  * boost::asio::io_service::post().
  */
 template <typename AsyncWriteStream, typename Allocator, typename WriteHandler>
-void async_write(AsyncWriteStream& s, basic_streambuf<Allocator>& b,
+BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write(AsyncWriteStream& s, basic_streambuf<Allocator>& b,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler);
 
 /// Start an asynchronous operation to write a certain amount of data to a
@@ -593,7 +600,9 @@
  */
 template <typename AsyncWriteStream, typename Allocator,
     typename CompletionCondition, typename WriteHandler>
-void async_write(AsyncWriteStream& s, basic_streambuf<Allocator>& b,
+BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write(AsyncWriteStream& s, basic_streambuf<Allocator>& b,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler);
 

Modified: trunk/boost/asio/write_at.hpp
==============================================================================
--- trunk/boost/asio/write_at.hpp (original)
+++ trunk/boost/asio/write_at.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -18,6 +18,7 @@
 #include <boost/asio/detail/config.hpp>
 #include <cstddef>
 #include <boost/cstdint.hpp>
+#include <boost/asio/async_result.hpp>
 #include <boost/asio/basic_streambuf_fwd.hpp>
 #include <boost/asio/error.hpp>
 
@@ -445,7 +446,9 @@
  */
 template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
     typename WriteHandler>
-void async_write_at(AsyncRandomAccessWriteDevice& d, boost::uint64_t offset,
+BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write_at(AsyncRandomAccessWriteDevice& d, boost::uint64_t offset,
     const ConstBufferSequence& buffers,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler);
 
@@ -517,7 +520,9 @@
  */
 template <typename AsyncRandomAccessWriteDevice, typename ConstBufferSequence,
     typename CompletionCondition, typename WriteHandler>
-void async_write_at(AsyncRandomAccessWriteDevice& d,
+BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write_at(AsyncRandomAccessWriteDevice& d,
     boost::uint64_t offset, const ConstBufferSequence& buffers,
     CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler);
@@ -566,7 +571,9 @@
  */
 template <typename AsyncRandomAccessWriteDevice, typename Allocator,
     typename WriteHandler>
-void async_write_at(AsyncRandomAccessWriteDevice& d, boost::uint64_t offset,
+BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write_at(AsyncRandomAccessWriteDevice& d, boost::uint64_t offset,
     basic_streambuf<Allocator>& b, BOOST_ASIO_MOVE_ARG(WriteHandler) handler);
 
 /// Start an asynchronous operation to write a certain amount of data at the
@@ -625,7 +632,9 @@
  */
 template <typename AsyncRandomAccessWriteDevice, typename Allocator,
     typename CompletionCondition, typename WriteHandler>
-void async_write_at(AsyncRandomAccessWriteDevice& d, boost::uint64_t offset,
+BOOST_ASIO_INITFN_RESULT_TYPE(WriteHandler,
+ void (boost::system::error_code, std::size_t))
+async_write_at(AsyncRandomAccessWriteDevice& d, boost::uint64_t offset,
     basic_streambuf<Allocator>& b, CompletionCondition completion_condition,
     BOOST_ASIO_MOVE_ARG(WriteHandler) handler);
 

Modified: trunk/libs/asio/doc/reference.dox
==============================================================================
--- trunk/libs/asio/doc/reference.dox (original)
+++ trunk/libs/asio/doc/reference.dox 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -195,7 +195,8 @@
                          BOOST_ASIO_EOF_ERROR(e)=implementation_defined \
                          BOOST_ASIO_OS_ERROR(e1,e2)=implementation_defined \
                          BOOST_ASIO_MOVE_ARG(a)=a \
- BOOST_ASIO_DECL=
+ BOOST_ASIO_DECL= \
+ BOOST_ASIO_INITFN_RESULT_TYPE(t,a)=void_or_deduced
 EXPAND_AS_DEFINED =
 SKIP_FUNCTION_MACROS = YES
 #---------------------------------------------------------------------------

Modified: trunk/libs/asio/doc/reference.xsl
==============================================================================
--- trunk/libs/asio/doc/reference.xsl (original)
+++ trunk/libs/asio/doc/reference.xsl 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -177,17 +177,27 @@
 
 <xsl:template name="cleanup-type">
   <xsl:param name="name"/>
+ <xsl:variable name="type">
+ <xsl:choose>
+ <xsl:when test="contains($name, 'BOOST_ASIO_DECL ')">
+ <xsl:value-of select="substring-after($name, 'BOOST_ASIO_DECL ')"/>
+ </xsl:when>
+ <xsl:when test="contains($name, 'BOOST_ASIO_DECL')">
+ <xsl:value-of select="substring-after($name, 'BOOST_ASIO_DECL')"/>
+ </xsl:when>
+ <xsl:when test="$name = 'virtual'"></xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$name"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
   <xsl:choose>
- <xsl:when test="contains($name, 'BOOST_ASIO_DECL ')">
- <xsl:value-of select="substring-after($name, 'BOOST_ASIO_DECL ')"/>
- </xsl:when>
- <xsl:when test="contains($name, 'BOOST_ASIO_DECL')">
- <xsl:value-of select="substring-after($name, 'BOOST_ASIO_DECL')"/>
- </xsl:when>
- <xsl:when test="$name = 'virtual'"></xsl:when>
+ <xsl:when test="$type='void_or_deduced'">
+ <xsl:text>``[link boost_asio.reference.asynchronous_operations.return_type ['void-or-deduced]]``</xsl:text>
+ </xsl:when>
     <xsl:otherwise>
- <xsl:value-of select="$name"/>
- </xsl:otherwise>
+ <xsl:value-of select="$type"/>
+ </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
 

Modified: trunk/libs/asio/doc/requirements/asynchronous_operations.qbk
==============================================================================
--- trunk/libs/asio/doc/requirements/asynchronous_operations.qbk (original)
+++ trunk/libs/asio/doc/requirements/asynchronous_operations.qbk 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -173,4 +173,8 @@
 `asio_handler_invoke`. Multiple storage blocks may be allocated for a single
 asynchronous operation.
 
+[section:return_type Return type of an initiating function]
+
+[endsect]
+
 [endsect]

Modified: trunk/libs/asio/test/Jamfile
==============================================================================
--- trunk/libs/asio/test/Jamfile (original)
+++ trunk/libs/asio/test/Jamfile 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -68,6 +68,7 @@
   [ run ip/basic_resolver_iterator.cpp <template>asio_unit_test ]
   [ run ip/basic_resolver_query.cpp <template>asio_unit_test ]
   [ run ip/host_name.cpp <template>asio_unit_test ]
+ [ run ip/icmp.cpp <template>asio_unit_test ]
   [ run ip/multicast.cpp <template>asio_unit_test ]
   [ run ip/resolver_query_base.cpp <template>asio_unit_test ]
   [ run ip/resolver_service.cpp <template>asio_unit_test ]

Modified: trunk/libs/asio/test/Jamfile.v2
==============================================================================
--- trunk/libs/asio/test/Jamfile.v2 (original)
+++ trunk/libs/asio/test/Jamfile.v2 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -123,6 +123,8 @@
   [ link ip/basic_resolver_query.cpp : $(USE_SELECT) : ip_basic_resolver_query_select ]
   [ run ip/host_name.cpp : : : : ip_host_name ]
   [ run ip/host_name.cpp : : : $(USE_SELECT) : ip_host_name_select ]
+ [ run ip/icmp.cpp : : : : ip_icmp ]
+ [ run ip/icmp.cpp : : : $(USE_SELECT) : ip_icmp_select ]
   [ run ip/multicast.cpp : : : : ip_multicast ]
   [ run ip/multicast.cpp : : : $(USE_SELECT) : ip_multicast_select ]
   [ link ip/resolver_query_base.cpp : : ip_resolver_query_base ]

Added: trunk/libs/asio/test/archetypes/async_result.hpp
==============================================================================
--- (empty file)
+++ trunk/libs/asio/test/archetypes/async_result.hpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -0,0 +1,73 @@
+//
+// async_result.hpp
+// ~~~~~~~~~~~~~~~~
+//
+// Copyright (c) 2003-2012 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)
+//
+
+#ifndef ARCHETYPES_ASYNC_RESULT_HPP
+#define ARCHETYPES_ASYNC_RESULT_HPP
+
+#include <boost/asio/async_result.hpp>
+#include <boost/asio/handler_type.hpp>
+
+namespace archetypes {
+
+struct lazy_handler
+{
+};
+
+struct concrete_handler
+{
+ concrete_handler(lazy_handler)
+ {
+ }
+
+ template <typename Arg1>
+ void operator()(Arg1)
+ {
+ }
+
+ template <typename Arg1, typename Arg2>
+ void operator()(Arg1, Arg2)
+ {
+ }
+};
+
+} // namespace archetypes
+
+namespace boost {
+namespace asio {
+
+template <typename Signature>
+struct handler_type<archetypes::lazy_handler, Signature>
+{
+ typedef archetypes::concrete_handler type;
+};
+
+template <>
+class async_result<archetypes::concrete_handler>
+{
+public:
+ // The return type of the initiating function.
+ typedef int type;
+
+ // Construct an async_result from a given handler.
+ explicit async_result(archetypes::concrete_handler&)
+ {
+ }
+
+ // Obtain the value to be returned from the initiating function.
+ type get()
+ {
+ return 42;
+ }
+};
+
+} // namespace asio
+} // namespace boost
+
+#endif // ARCHETYPES_ASYNC_RESULT_HPP

Modified: trunk/libs/asio/test/deadline_timer.cpp
==============================================================================
--- trunk/libs/asio/test/deadline_timer.cpp (original)
+++ trunk/libs/asio/test/deadline_timer.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -18,6 +18,7 @@
 
 #include <boost/thread/thread.hpp>
 #include <boost/bind.hpp>
+#include "archetypes/async_result.hpp"
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/placeholders.hpp>
 #include "unit_test.hpp"
@@ -322,6 +323,18 @@
   BOOST_CHECK(count == 1);
 }
 
+void deadline_timer_async_result_test()
+{
+ boost::asio::io_service ios;
+ boost::asio::deadline_timer t1(ios);
+
+ t1.expires_from_now(boost::posix_time::seconds(1));
+ int i = t1.async_wait(archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+
+ ios.run();
+}
+
 test_suite* init_unit_test_suite(int, char*[])
 {
   test_suite* test = BOOST_TEST_SUITE("deadline_timer");
@@ -329,5 +342,6 @@
   test->add(BOOST_TEST_CASE(&deadline_timer_cancel_test));
   test->add(BOOST_TEST_CASE(&deadline_timer_custom_allocation_test));
   test->add(BOOST_TEST_CASE(&deadline_timer_thread_test));
+ test->add(BOOST_TEST_CASE(&deadline_timer_async_result_test));
   return test;
 }

Added: trunk/libs/asio/test/ip/icmp.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/asio/test/ip/icmp.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -0,0 +1,460 @@
+//
+// icmp.cpp
+// ~~~~~~~~
+//
+// Copyright (c) 2003-2012 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)
+//
+
+// Disable autolinking for unit tests.
+#if !defined(BOOST_ALL_NO_LIB)
+#define BOOST_ALL_NO_LIB 1
+#endif // !defined(BOOST_ALL_NO_LIB)
+
+// Test that header file is self-contained.
+#include <boost/asio/ip/icmp.hpp>
+
+#include <boost/bind.hpp>
+#include <cstring>
+#include <boost/asio/io_service.hpp>
+#include <boost/asio/placeholders.hpp>
+#include "../unit_test.hpp"
+#include "../archetypes/gettable_socket_option.hpp"
+#include "../archetypes/async_result.hpp"
+#include "../archetypes/io_control_command.hpp"
+#include "../archetypes/settable_socket_option.hpp"
+
+//------------------------------------------------------------------------------
+
+// ip_icmp_socket_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::icmp::socket compile and link correctly. Runtime failures are ignored.
+
+namespace ip_icmp_socket_compile {
+
+void connect_handler(const boost::system::error_code&)
+{
+}
+
+void send_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void receive_handler(const boost::system::error_code&, std::size_t)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_service ios;
+ char mutable_char_buffer[128] = "";
+ const char const_char_buffer[128] = "";
+ socket_base::message_flags in_flags = 0;
+ archetypes::settable_socket_option<void> settable_socket_option1;
+ archetypes::settable_socket_option<int> settable_socket_option2;
+ archetypes::settable_socket_option<double> settable_socket_option3;
+ archetypes::gettable_socket_option<void> gettable_socket_option1;
+ archetypes::gettable_socket_option<int> gettable_socket_option2;
+ archetypes::gettable_socket_option<double> gettable_socket_option3;
+ archetypes::io_control_command io_control_command;
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+
+ // basic_datagram_socket constructors.
+
+ ip::icmp::socket socket1(ios);
+ ip::icmp::socket socket2(ios, ip::icmp::v4());
+ ip::icmp::socket socket3(ios, ip::icmp::v6());
+ ip::icmp::socket socket4(ios, ip::icmp::endpoint(ip::icmp::v4(), 0));
+ ip::icmp::socket socket5(ios, ip::icmp::endpoint(ip::icmp::v6(), 0));
+ int native_socket1 = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ ip::icmp::socket socket6(ios, ip::icmp::v4(), native_socket1);
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ ip::icmp::socket socket7(std::move(socket6));
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_datagram_socket operators.
+
+#if defined(BOOST_ASIO_HAS_MOVE)
+ socket1 = ip::icmp::socket(ios);
+ socket1 = std::move(socket2);
+#endif // defined(BOOST_ASIO_HAS_MOVE)
+
+ // basic_io_object functions.
+
+ io_service& ios_ref = socket1.get_io_service();
+ (void)ios_ref;
+
+ // basic_socket functions.
+
+ ip::icmp::socket::lowest_layer_type& lowest_layer = socket1.lowest_layer();
+ (void)lowest_layer;
+
+ const ip::icmp::socket& socket8 = socket1;
+ const ip::icmp::socket::lowest_layer_type& lowest_layer2
+ = socket8.lowest_layer();
+ (void)lowest_layer2;
+
+ socket1.open(ip::icmp::v4());
+ socket1.open(ip::icmp::v6());
+ socket1.open(ip::icmp::v4(), ec);
+ socket1.open(ip::icmp::v6(), ec);
+
+ int native_socket2 = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ socket1.assign(ip::icmp::v4(), native_socket2);
+ int native_socket3 = ::socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ socket1.assign(ip::icmp::v4(), native_socket3, ec);
+
+ bool is_open = socket1.is_open();
+ (void)is_open;
+
+ socket1.close();
+ socket1.close(ec);
+
+ ip::icmp::socket::native_type native_socket4 = socket1.native();
+ (void)native_socket4;
+
+ ip::icmp::socket::native_handle_type native_socket5
+ = socket1.native_handle();
+ (void)native_socket5;
+
+ socket1.cancel();
+ socket1.cancel(ec);
+
+ bool at_mark1 = socket1.at_mark();
+ (void)at_mark1;
+ bool at_mark2 = socket1.at_mark(ec);
+ (void)at_mark2;
+
+ std::size_t available1 = socket1.available();
+ (void)available1;
+ std::size_t available2 = socket1.available(ec);
+ (void)available2;
+
+ socket1.bind(ip::icmp::endpoint(ip::icmp::v4(), 0));
+ socket1.bind(ip::icmp::endpoint(ip::icmp::v6(), 0));
+ socket1.bind(ip::icmp::endpoint(ip::icmp::v4(), 0), ec);
+ socket1.bind(ip::icmp::endpoint(ip::icmp::v6(), 0), ec);
+
+ socket1.connect(ip::icmp::endpoint(ip::icmp::v4(), 0));
+ socket1.connect(ip::icmp::endpoint(ip::icmp::v6(), 0));
+ socket1.connect(ip::icmp::endpoint(ip::icmp::v4(), 0), ec);
+ socket1.connect(ip::icmp::endpoint(ip::icmp::v6(), 0), ec);
+
+ socket1.async_connect(ip::icmp::endpoint(ip::icmp::v4(), 0),
+ &connect_handler);
+ socket1.async_connect(ip::icmp::endpoint(ip::icmp::v6(), 0),
+ &connect_handler);
+ int i1 = socket1.async_connect(ip::icmp::endpoint(ip::icmp::v4(), 0), lazy);
+ (void)i1;
+ int i2 = socket1.async_connect(ip::icmp::endpoint(ip::icmp::v6(), 0), lazy);
+ (void)i2;
+
+ socket1.set_option(settable_socket_option1);
+ socket1.set_option(settable_socket_option1, ec);
+ socket1.set_option(settable_socket_option2);
+ socket1.set_option(settable_socket_option2, ec);
+ socket1.set_option(settable_socket_option3);
+ socket1.set_option(settable_socket_option3, ec);
+
+ socket1.get_option(gettable_socket_option1);
+ socket1.get_option(gettable_socket_option1, ec);
+ socket1.get_option(gettable_socket_option2);
+ socket1.get_option(gettable_socket_option2, ec);
+ socket1.get_option(gettable_socket_option3);
+ socket1.get_option(gettable_socket_option3, ec);
+
+ socket1.io_control(io_control_command);
+ socket1.io_control(io_control_command, ec);
+
+ bool non_blocking1 = socket1.non_blocking();
+ (void)non_blocking1;
+ socket1.non_blocking(true);
+ socket1.non_blocking(false, ec);
+
+ bool non_blocking2 = socket1.native_non_blocking();
+ (void)non_blocking2;
+ socket1.native_non_blocking(true);
+ socket1.native_non_blocking(false, ec);
+
+ ip::icmp::endpoint endpoint1 = socket1.local_endpoint();
+ ip::icmp::endpoint endpoint2 = socket1.local_endpoint(ec);
+
+ ip::icmp::endpoint endpoint3 = socket1.remote_endpoint();
+ ip::icmp::endpoint endpoint4 = socket1.remote_endpoint(ec);
+
+ socket1.shutdown(socket_base::shutdown_both);
+ socket1.shutdown(socket_base::shutdown_both, ec);
+
+ // basic_datagram_socket functions.
+
+ socket1.send(buffer(mutable_char_buffer));
+ socket1.send(buffer(const_char_buffer));
+ socket1.send(null_buffers());
+ socket1.send(buffer(mutable_char_buffer), in_flags);
+ socket1.send(buffer(const_char_buffer), in_flags);
+ socket1.send(null_buffers(), in_flags);
+ socket1.send(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.send(buffer(const_char_buffer), in_flags, ec);
+ socket1.send(null_buffers(), in_flags, ec);
+
+ socket1.async_send(buffer(mutable_char_buffer), &send_handler);
+ socket1.async_send(buffer(const_char_buffer), &send_handler);
+ socket1.async_send(null_buffers(), &send_handler);
+ socket1.async_send(buffer(mutable_char_buffer), in_flags, &send_handler);
+ socket1.async_send(buffer(const_char_buffer), in_flags, &send_handler);
+ socket1.async_send(null_buffers(), in_flags, &send_handler);
+ int i3 = socket1.async_send(buffer(mutable_char_buffer), lazy);
+ (void)i3;
+ int i4 = socket1.async_send(buffer(const_char_buffer), lazy);
+ (void)i4;
+ int i5 = socket1.async_send(null_buffers(), lazy);
+ (void)i5;
+ int i6 = socket1.async_send(buffer(mutable_char_buffer), in_flags, lazy);
+ (void)i6;
+ int i7 = socket1.async_send(buffer(const_char_buffer), in_flags, lazy);
+ (void)i7;
+ int i8 = socket1.async_send(null_buffers(), in_flags, lazy);
+ (void)i8;
+
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0));
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0));
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0));
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0));
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0));
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0));
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags);
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags);
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags);
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, ec);
+ socket1.send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, ec);
+ socket1.send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, ec);
+ socket1.send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, ec);
+
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), &send_handler);
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), &send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), &send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), &send_handler);
+ socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), &send_handler);
+ socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), &send_handler);
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, &send_handler);
+ socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, &send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, &send_handler);
+ socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, &send_handler);
+ socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, &send_handler);
+ socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, &send_handler);
+ int i9 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), lazy);
+ (void)i9;
+ int i10 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), lazy);
+ (void)i10;
+ int i11 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), lazy);
+ (void)i11;
+ int i12 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), lazy);
+ (void)i12;
+ int i13 = socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), lazy);
+ (void)i13;
+ int i14 = socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), lazy);
+ (void)i14;
+ int i15 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, lazy);
+ (void)i15;
+ int i16 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, lazy);
+ (void)i16;
+ int i17 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, lazy);
+ (void)i17;
+ int i18 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, lazy);
+ (void)i18;
+ int i19 = socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v4(), 0), in_flags, lazy);
+ (void)i19;
+ int i20 = socket1.async_send_to(null_buffers(),
+ ip::icmp::endpoint(ip::icmp::v6(), 0), in_flags, lazy);
+ (void)i20;
+
+ socket1.receive(buffer(mutable_char_buffer));
+ socket1.receive(null_buffers());
+ socket1.receive(buffer(mutable_char_buffer), in_flags);
+ socket1.receive(null_buffers(), in_flags);
+ socket1.receive(buffer(mutable_char_buffer), in_flags, ec);
+ socket1.receive(null_buffers(), in_flags, ec);
+
+ socket1.async_receive(buffer(mutable_char_buffer), &receive_handler);
+ socket1.async_receive(null_buffers(), &receive_handler);
+ socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ &receive_handler);
+ socket1.async_receive(null_buffers(), in_flags, &receive_handler);
+ int i21 = socket1.async_receive(buffer(mutable_char_buffer), lazy);
+ (void)i21;
+ int i22 = socket1.async_receive(null_buffers(), lazy);
+ (void)i22;
+ int i23 = socket1.async_receive(buffer(mutable_char_buffer),
+ in_flags, lazy);
+ (void)i23;
+ int i24 = socket1.async_receive(null_buffers(), in_flags, lazy);
+ (void)i24;
+
+ ip::icmp::endpoint endpoint;
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint);
+ socket1.receive_from(null_buffers(), endpoint);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags);
+ socket1.receive_from(null_buffers(), endpoint, in_flags);
+ socket1.receive_from(buffer(mutable_char_buffer), endpoint, in_flags, ec);
+ socket1.receive_from(null_buffers(), endpoint, in_flags, ec);
+
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, &receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, &receive_handler);
+ socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, &receive_handler);
+ socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, &receive_handler);
+ int i25 = socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, lazy);
+ (void)i25;
+ int i26 = socket1.async_receive_from(null_buffers(),
+ endpoint, lazy);
+ (void)i26;
+ int i27 = socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, lazy);
+ (void)i27;
+ int i28 = socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, lazy);
+ (void)i28;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_icmp_socket_compile
+
+//------------------------------------------------------------------------------
+
+// ip_icmp_resolver_compile test
+// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// The following test checks that all public member functions on the class
+// ip::icmp::resolver compile and link correctly. Runtime failures are ignored.
+
+namespace ip_icmp_resolver_compile {
+
+void resolve_handler(const boost::system::error_code&,
+ boost::asio::ip::icmp::resolver::iterator)
+{
+}
+
+void test()
+{
+ using namespace boost::asio;
+ namespace ip = boost::asio::ip;
+
+ try
+ {
+ io_service ios;
+ archetypes::lazy_handler lazy;
+ boost::system::error_code ec;
+ ip::icmp::resolver::query q(ip::icmp::v4(), "localhost", "0");
+ ip::icmp::endpoint e(ip::address_v4::loopback(), 0);
+
+ // basic_resolver constructors.
+
+ ip::icmp::resolver resolver(ios);
+
+ // basic_io_object functions.
+
+ io_service& ios_ref = resolver.get_io_service();
+ (void)ios_ref;
+
+ // basic_resolver functions.
+
+ resolver.cancel();
+
+ ip::icmp::resolver::iterator iter1 = resolver.resolve(q);
+ (void)iter1;
+
+ ip::icmp::resolver::iterator iter2 = resolver.resolve(q, ec);
+ (void)iter2;
+
+ ip::icmp::resolver::iterator iter3 = resolver.resolve(e);
+ (void)iter3;
+
+ ip::icmp::resolver::iterator iter4 = resolver.resolve(e, ec);
+ (void)iter4;
+
+ resolver.async_resolve(q, &resolve_handler);
+ int i1 = resolver.async_resolve(q, lazy);
+ (void)i1;
+
+ resolver.async_resolve(e, &resolve_handler);
+ int i2 = resolver.async_resolve(e, lazy);
+ (void)i2;
+ }
+ catch (std::exception&)
+ {
+ }
+}
+
+} // namespace ip_icmp_resolver_compile
+
+//------------------------------------------------------------------------------
+
+test_suite* init_unit_test_suite(int, char*[])
+{
+ test_suite* test = BOOST_TEST_SUITE("ip/icmp");
+ test->add(BOOST_TEST_CASE(&ip_icmp_socket_compile::test));
+ test->add(BOOST_TEST_CASE(&ip_icmp_resolver_compile::test));
+ return test;
+}

Modified: trunk/libs/asio/test/ip/tcp.cpp
==============================================================================
--- trunk/libs/asio/test/ip/tcp.cpp (original)
+++ trunk/libs/asio/test/ip/tcp.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -28,6 +28,7 @@
 #include <boost/asio/write.hpp>
 #include "../unit_test.hpp"
 #include "../archetypes/gettable_socket_option.hpp"
+#include "../archetypes/async_result.hpp"
 #include "../archetypes/io_control_command.hpp"
 #include "../archetypes/settable_socket_option.hpp"
 
@@ -171,6 +172,7 @@
     archetypes::gettable_socket_option<int> gettable_socket_option2;
     archetypes::gettable_socket_option<double> gettable_socket_option3;
     archetypes::io_control_command io_control_command;
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
 
     // basic_stream_socket constructors.
@@ -259,6 +261,10 @@
         &connect_handler);
     socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0),
         &connect_handler);
+ int i1 = socket1.async_connect(ip::tcp::endpoint(ip::tcp::v4(), 0), lazy);
+ (void)i1;
+ int i2 = socket1.async_connect(ip::tcp::endpoint(ip::tcp::v6(), 0), lazy);
+ (void)i2;
 
     socket1.set_option(settable_socket_option1);
     socket1.set_option(settable_socket_option1, ec);
@@ -324,6 +330,26 @@
     socket1.async_send(mutable_buffers, in_flags, &send_handler);
     socket1.async_send(const_buffers, in_flags, &send_handler);
     socket1.async_send(null_buffers(), in_flags, &send_handler);
+ int i3 = socket1.async_send(buffer(mutable_char_buffer), lazy);
+ (void)i3;
+ int i4 = socket1.async_send(buffer(const_char_buffer), lazy);
+ (void)i4;
+ int i5 = socket1.async_send(mutable_buffers, lazy);
+ (void)i5;
+ int i6 = socket1.async_send(const_buffers, lazy);
+ (void)i6;
+ int i7 = socket1.async_send(null_buffers(), lazy);
+ (void)i7;
+ int i8 = socket1.async_send(buffer(mutable_char_buffer), in_flags, lazy);
+ (void)i8;
+ int i9 = socket1.async_send(buffer(const_char_buffer), in_flags, lazy);
+ (void)i9;
+ int i10 = socket1.async_send(mutable_buffers, in_flags, lazy);
+ (void)i10;
+ int i11 = socket1.async_send(const_buffers, in_flags, lazy);
+ (void)i11;
+ int i12 = socket1.async_send(null_buffers(), in_flags, lazy);
+ (void)i12;
 
     socket1.receive(buffer(mutable_char_buffer));
     socket1.receive(mutable_buffers);
@@ -342,6 +368,19 @@
         &receive_handler);
     socket1.async_receive(mutable_buffers, in_flags, &receive_handler);
     socket1.async_receive(null_buffers(), in_flags, &receive_handler);
+ int i13 = socket1.async_receive(buffer(mutable_char_buffer), lazy);
+ (void)i13;
+ int i14 = socket1.async_receive(mutable_buffers, lazy);
+ (void)i14;
+ int i15 = socket1.async_receive(null_buffers(), lazy);
+ (void)i15;
+ int i16 = socket1.async_receive(buffer(mutable_char_buffer), in_flags,
+ lazy);
+ (void)i16;
+ int i17 = socket1.async_receive(mutable_buffers, in_flags, lazy);
+ (void)i17;
+ int i18 = socket1.async_receive(null_buffers(), in_flags, lazy);
+ (void)i18;
 
     socket1.write_some(buffer(mutable_char_buffer));
     socket1.write_some(buffer(const_char_buffer));
@@ -359,6 +398,16 @@
     socket1.async_write_some(mutable_buffers, &write_some_handler);
     socket1.async_write_some(const_buffers, &write_some_handler);
     socket1.async_write_some(null_buffers(), &write_some_handler);
+ int i19 = socket1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i19;
+ int i20 = socket1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i20;
+ int i21 = socket1.async_write_some(mutable_buffers, lazy);
+ (void)i21;
+ int i22 = socket1.async_write_some(const_buffers, lazy);
+ (void)i22;
+ int i23 = socket1.async_write_some(null_buffers(), lazy);
+ (void)i23;
 
     socket1.read_some(buffer(mutable_char_buffer));
     socket1.read_some(mutable_buffers);
@@ -370,6 +419,12 @@
     socket1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
     socket1.async_read_some(mutable_buffers, &read_some_handler);
     socket1.async_read_some(null_buffers(), &read_some_handler);
+ int i24 = socket1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i24;
+ int i25 = socket1.async_read_some(mutable_buffers, lazy);
+ (void)i25;
+ int i26 = socket1.async_read_some(null_buffers(), lazy);
+ (void)i26;
   }
   catch (std::exception&)
   {
@@ -576,6 +631,7 @@
     archetypes::gettable_socket_option<int> gettable_socket_option2;
     archetypes::gettable_socket_option<double> gettable_socket_option3;
     archetypes::io_control_command io_control_command;
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
 
     // basic_socket_acceptor constructors.
@@ -674,6 +730,10 @@
 
     acceptor1.async_accept(peer_socket, &accept_handler);
     acceptor1.async_accept(peer_socket, peer_endpoint, &accept_handler);
+ int i1 = acceptor1.async_accept(peer_socket, lazy);
+ (void)i1;
+ int i2 = acceptor1.async_accept(peer_socket, peer_endpoint, lazy);
+ (void)i2;
   }
   catch (std::exception&)
   {
@@ -784,6 +844,7 @@
   try
   {
     io_service ios;
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
     ip::tcp::resolver::query q(ip::tcp::v4(), "localhost", "0");
     ip::tcp::endpoint e(ip::address_v4::loopback(), 0);
@@ -814,8 +875,12 @@
     (void)iter4;
 
     resolver.async_resolve(q, &resolve_handler);
+ int i1 = resolver.async_resolve(q, lazy);
+ (void)i1;
 
     resolver.async_resolve(e, &resolve_handler);
+ int i2 = resolver.async_resolve(e, lazy);
+ (void)i2;
   }
   catch (std::exception&)
   {

Modified: trunk/libs/asio/test/ip/udp.cpp
==============================================================================
--- trunk/libs/asio/test/ip/udp.cpp (original)
+++ trunk/libs/asio/test/ip/udp.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -22,6 +22,7 @@
 #include <boost/asio/placeholders.hpp>
 #include "../unit_test.hpp"
 #include "../archetypes/gettable_socket_option.hpp"
+#include "../archetypes/async_result.hpp"
 #include "../archetypes/io_control_command.hpp"
 #include "../archetypes/settable_socket_option.hpp"
 
@@ -64,6 +65,7 @@
     archetypes::gettable_socket_option<int> gettable_socket_option2;
     archetypes::gettable_socket_option<double> gettable_socket_option3;
     archetypes::io_control_command io_control_command;
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
 
     // basic_datagram_socket constructors.
@@ -152,6 +154,10 @@
         &connect_handler);
     socket1.async_connect(ip::udp::endpoint(ip::udp::v6(), 0),
         &connect_handler);
+ int i1 = socket1.async_connect(ip::udp::endpoint(ip::udp::v4(), 0), lazy);
+ (void)i1;
+ int i2 = socket1.async_connect(ip::udp::endpoint(ip::udp::v6(), 0), lazy);
+ (void)i2;
 
     socket1.set_option(settable_socket_option1);
     socket1.set_option(settable_socket_option1, ec);
@@ -207,6 +213,18 @@
     socket1.async_send(buffer(mutable_char_buffer), in_flags, &send_handler);
     socket1.async_send(buffer(const_char_buffer), in_flags, &send_handler);
     socket1.async_send(null_buffers(), in_flags, &send_handler);
+ int i3 = socket1.async_send(buffer(mutable_char_buffer), lazy);
+ (void)i3;
+ int i4 = socket1.async_send(buffer(const_char_buffer), lazy);
+ (void)i4;
+ int i5 = socket1.async_send(null_buffers(), lazy);
+ (void)i5;
+ int i6 = socket1.async_send(buffer(mutable_char_buffer), in_flags, lazy);
+ (void)i6;
+ int i7 = socket1.async_send(buffer(const_char_buffer), in_flags, lazy);
+ (void)i7;
+ int i8 = socket1.async_send(null_buffers(), in_flags, lazy);
+ (void)i8;
 
     socket1.send_to(buffer(mutable_char_buffer),
         ip::udp::endpoint(ip::udp::v4(), 0));
@@ -269,6 +287,42 @@
         ip::udp::endpoint(ip::udp::v4(), 0), in_flags, &send_handler);
     socket1.async_send_to(null_buffers(),
         ip::udp::endpoint(ip::udp::v6(), 0), in_flags, &send_handler);
+ int i9 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), lazy);
+ (void)i9;
+ int i10 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), lazy);
+ (void)i10;
+ int i11 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), lazy);
+ (void)i11;
+ int i12 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), lazy);
+ (void)i12;
+ int i13 = socket1.async_send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v4(), 0), lazy);
+ (void)i13;
+ int i14 = socket1.async_send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v6(), 0), lazy);
+ (void)i14;
+ int i15 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, lazy);
+ (void)i15;
+ int i16 = socket1.async_send_to(buffer(mutable_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, lazy);
+ (void)i16;
+ int i17 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, lazy);
+ (void)i17;
+ int i18 = socket1.async_send_to(buffer(const_char_buffer),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, lazy);
+ (void)i18;
+ int i19 = socket1.async_send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v4(), 0), in_flags, lazy);
+ (void)i19;
+ int i20 = socket1.async_send_to(null_buffers(),
+ ip::udp::endpoint(ip::udp::v6(), 0), in_flags, lazy);
+ (void)i20;
 
     socket1.receive(buffer(mutable_char_buffer));
     socket1.receive(null_buffers());
@@ -282,6 +336,15 @@
     socket1.async_receive(buffer(mutable_char_buffer), in_flags,
         &receive_handler);
     socket1.async_receive(null_buffers(), in_flags, &receive_handler);
+ int i21 = socket1.async_receive(buffer(mutable_char_buffer), lazy);
+ (void)i21;
+ int i22 = socket1.async_receive(null_buffers(), lazy);
+ (void)i22;
+ int i23 = socket1.async_receive(buffer(mutable_char_buffer),
+ in_flags, lazy);
+ (void)i23;
+ int i24 = socket1.async_receive(null_buffers(), in_flags, lazy);
+ (void)i24;
 
     ip::udp::endpoint endpoint;
     socket1.receive_from(buffer(mutable_char_buffer), endpoint);
@@ -299,6 +362,18 @@
         endpoint, in_flags, &receive_handler);
     socket1.async_receive_from(null_buffers(),
         endpoint, in_flags, &receive_handler);
+ int i25 = socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, lazy);
+ (void)i25;
+ int i26 = socket1.async_receive_from(null_buffers(),
+ endpoint, lazy);
+ (void)i26;
+ int i27 = socket1.async_receive_from(buffer(mutable_char_buffer),
+ endpoint, in_flags, lazy);
+ (void)i27;
+ int i28 = socket1.async_receive_from(null_buffers(),
+ endpoint, in_flags, lazy);
+ (void)i28;
   }
   catch (std::exception&)
   {
@@ -396,6 +471,7 @@
   try
   {
     io_service ios;
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
     ip::udp::resolver::query q(ip::udp::v4(), "localhost", "0");
     ip::udp::endpoint e(ip::address_v4::loopback(), 0);
@@ -426,8 +502,12 @@
     (void)iter4;
 
     resolver.async_resolve(q, &resolve_handler);
+ int i1 = resolver.async_resolve(q, lazy);
+ (void)i1;
 
     resolver.async_resolve(e, &resolve_handler);
+ int i2 = resolver.async_resolve(e, lazy);
+ (void)i2;
   }
   catch (std::exception&)
   {

Modified: trunk/libs/asio/test/posix/stream_descriptor.cpp
==============================================================================
--- trunk/libs/asio/test/posix/stream_descriptor.cpp (original)
+++ trunk/libs/asio/test/posix/stream_descriptor.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 #include <boost/asio/posix/stream_descriptor.hpp>
 
 #include <boost/asio/io_service.hpp>
+#include "../archetypes/async_result.hpp"
 #include "../unit_test.hpp"
 
 //------------------------------------------------------------------------------
@@ -49,6 +50,7 @@
     char mutable_char_buffer[128] = "";
     const char const_char_buffer[128] = "";
     posix::descriptor_base::bytes_readable io_control_command;
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
 
     // basic_stream_descriptor constructors.
@@ -136,6 +138,12 @@
         write_some_handler);
     descriptor1.async_write_some(null_buffers(),
         write_some_handler);
+ int i1 = descriptor1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i1;
+ int i2 = descriptor1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i2;
+ int i3 = descriptor1.async_write_some(null_buffers(), lazy);
+ (void)i3;
 
     descriptor1.read_some(buffer(mutable_char_buffer));
     descriptor1.read_some(buffer(mutable_char_buffer), ec);
@@ -143,6 +151,10 @@
 
     descriptor1.async_read_some(buffer(mutable_char_buffer), read_some_handler);
     descriptor1.async_read_some(null_buffers(), read_some_handler);
+ int i4 = descriptor1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i4;
+ int i5 = descriptor1.async_read_some(null_buffers(), lazy);
+ (void)i5;
   }
   catch (std::exception&)
   {

Modified: trunk/libs/asio/test/read.cpp
==============================================================================
--- trunk/libs/asio/test/read.cpp (original)
+++ trunk/libs/asio/test/read.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -24,6 +24,7 @@
 #include <boost/noncopyable.hpp>
 #include <cstring>
 #include <vector>
+#include "archetypes/async_result.hpp"
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/placeholders.hpp>
 #include <boost/asio/streambuf.hpp>
@@ -1883,6 +1884,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
 }
 
 void test_3_arg_boost_array_buffers_async_read()
@@ -1934,6 +1943,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
 }
 
 void test_3_arg_std_array_buffers_async_read()
@@ -1986,6 +2003,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
 }
 
@@ -2038,6 +2063,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
 }
 
 void test_3_arg_streambuf_async_read()
@@ -2089,6 +2122,15 @@
   BOOST_CHECK(called);
   BOOST_CHECK(sb.size() == sizeof(read_data));
   BOOST_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ int i = boost::asio::async_read(s, sb, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(sb.size() == sizeof(read_data));
+ BOOST_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
 }
 
 void test_4_arg_mutable_buffers_1_async_read()
@@ -2467,6 +2509,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers,
+ short_transfer, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
 }
 
 void test_4_arg_boost_array_buffers_async_read()
@@ -2846,6 +2897,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers,
+ short_transfer, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
 }
 
 void test_4_arg_std_array_buffers_async_read()
@@ -3226,6 +3286,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers,
+ short_transfer, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
 }
 
@@ -3606,6 +3675,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read(s, buffers,
+ short_transfer, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(read_data)));
 }
 
 void test_4_arg_streambuf_async_read()
@@ -4009,6 +4087,16 @@
   BOOST_CHECK(called);
   BOOST_CHECK(sb.size() == sizeof(read_data));
   BOOST_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ int i = boost::asio::async_read(s, sb,
+ short_transfer, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(sb.size() == sizeof(read_data));
+ BOOST_CHECK(s.check_buffers(sb.data(), sizeof(read_data)));
 }
 
 test_suite* init_unit_test_suite(int, char*[])

Modified: trunk/libs/asio/test/read_at.cpp
==============================================================================
--- trunk/libs/asio/test/read_at.cpp (original)
+++ trunk/libs/asio/test/read_at.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -23,6 +23,7 @@
 #include <boost/bind.hpp>
 #include <boost/noncopyable.hpp>
 #include <cstring>
+#include "archetypes/async_result.hpp"
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/placeholders.hpp>
 #include <boost/asio/streambuf.hpp>
@@ -3496,6 +3497,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
 }
 
 void test_4_arg_boost_array_buffers_async_read_at()
@@ -3588,6 +3598,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
 }
 
 void test_4_arg_std_array_buffers_async_read_at()
@@ -3681,6 +3700,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
 }
 
@@ -3774,6 +3802,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
 }
 
 void test_4_arg_streambuf_async_read_at()
@@ -3869,6 +3906,15 @@
   BOOST_CHECK(called);
   BOOST_CHECK(sb.size() == sizeof(read_data));
   BOOST_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ int i = boost::asio::async_read_at(s, 1234, sb,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
 }
 
 void test_5_arg_mutable_buffers_1_async_read_at()
@@ -4658,6 +4704,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ short_transfer, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
 }
 
 void test_5_arg_boost_array_buffers_async_read_at()
@@ -5448,6 +5503,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ short_transfer, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
 }
 
 void test_5_arg_std_array_buffers_async_read_at()
@@ -6239,6 +6303,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ short_transfer, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
 }
 
@@ -7030,6 +7103,15 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ memset(read_buf, 0, sizeof(read_buf));
+ int i = boost::asio::async_read_at(s, 1234, buffers,
+ short_transfer, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(read_data)));
 }
 
 void test_5_arg_streambuf_async_read_at()
@@ -7871,6 +7953,15 @@
   BOOST_CHECK(called);
   BOOST_CHECK(sb.size() == sizeof(read_data));
   BOOST_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
+
+ s.reset(read_data, sizeof(read_data));
+ sb.consume(sb.size());
+ int i = boost::asio::async_read_at(s, 1234, sb,
+ short_transfer, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(1234, sb.data(), sizeof(read_data)));
 }
 
 test_suite* init_unit_test_suite(int, char*[])

Modified: trunk/libs/asio/test/read_until.cpp
==============================================================================
--- trunk/libs/asio/test/read_until.cpp (original)
+++ trunk/libs/asio/test/read_until.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -19,6 +19,7 @@
 #include <boost/bind.hpp>
 #include <boost/noncopyable.hpp>
 #include <cstring>
+#include "archetypes/async_result.hpp"
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/placeholders.hpp>
 #include <boost/asio/streambuf.hpp>
@@ -533,6 +534,14 @@
   BOOST_CHECK(called);
   BOOST_CHECK(!ec);
   BOOST_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ int i = boost::asio::async_read_until(s, sb2, 'Y',
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
 }
 
 void test_string_async_read_until()
@@ -676,6 +685,14 @@
   BOOST_CHECK(called);
   BOOST_CHECK(!ec);
   BOOST_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ int i = boost::asio::async_read_until(s, sb2, "WXY",
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
 }
 
 void test_match_condition_async_read_until()
@@ -819,6 +836,14 @@
   BOOST_CHECK(called);
   BOOST_CHECK(!ec);
   BOOST_CHECK(length == 25);
+
+ s.reset(read_data, sizeof(read_data));
+ sb2.consume(sb2.size());
+ int i = boost::asio::async_read_until(s, sb2, match_char('Y'),
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
 }
 
 test_suite* init_unit_test_suite(int, char*[])

Modified: trunk/libs/asio/test/serial_port.cpp
==============================================================================
--- trunk/libs/asio/test/serial_port.cpp (original)
+++ trunk/libs/asio/test/serial_port.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 // Test that header file is self-contained.
 #include <boost/asio/serial_port.hpp>
 
+#include "archetypes/async_result.hpp"
 #include <boost/asio/io_service.hpp>
 #include "unit_test.hpp"
 
@@ -48,6 +49,7 @@
     char mutable_char_buffer[128] = "";
     const char const_char_buffer[128] = "";
     serial_port::baud_rate serial_port_option;
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
 
     // basic_serial_port constructors.
@@ -121,11 +123,17 @@
 
     port1.async_write_some(buffer(mutable_char_buffer), &write_some_handler);
     port1.async_write_some(buffer(const_char_buffer), &write_some_handler);
+ int i1 = port1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i1;
+ int i2 = port1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i2;
 
     port1.read_some(buffer(mutable_char_buffer));
     port1.read_some(buffer(mutable_char_buffer), ec);
 
     port1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
+ int i3 = port1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i3;
   }
   catch (std::exception&)
   {

Modified: trunk/libs/asio/test/signal_set.cpp
==============================================================================
--- trunk/libs/asio/test/signal_set.cpp (original)
+++ trunk/libs/asio/test/signal_set.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -16,6 +16,7 @@
 // Test that header file is self-contained.
 #include <boost/asio/signal_set.hpp>
 
+#include "archetypes/async_result.hpp"
 #include <boost/asio/io_service.hpp>
 #include "unit_test.hpp"
 
@@ -39,6 +40,7 @@
   try
   {
     io_service ios;
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
 
     // basic_signal_set constructors.
@@ -68,6 +70,8 @@
     set1.cancel(ec);
 
     set1.async_wait(&signal_handler);
+ int i = set1.async_wait(lazy);
+ (void)i;
   }
   catch (std::exception&)
   {

Modified: trunk/libs/asio/test/ssl/stream.cpp
==============================================================================
--- trunk/libs/asio/test/ssl/stream.cpp (original)
+++ trunk/libs/asio/test/ssl/stream.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -18,6 +18,7 @@
 
 #include <boost/asio.hpp>
 #include <boost/asio/ssl.hpp>
+#include "../archetypes/async_result.hpp"
 #include "../unit_test.hpp"
 
 //------------------------------------------------------------------------------
@@ -63,6 +64,7 @@
     char mutable_char_buffer[128] = "";
     const char const_char_buffer[128] = "";
     boost::asio::ssl::context context(ios, boost::asio::ssl::context::sslv23);
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
 
     // ssl::stream constructors.
@@ -110,11 +112,17 @@
 
     stream1.async_handshake(ssl::stream_base::client, handshake_handler);
     stream1.async_handshake(ssl::stream_base::server, handshake_handler);
+ int i1 = stream1.async_handshake(ssl::stream_base::client, lazy);
+ (void)i1;
+ int i2 = stream1.async_handshake(ssl::stream_base::server, lazy);
+ (void)i2;
 
     stream1.shutdown();
     stream1.shutdown(ec);
 
     stream1.async_shutdown(shutdown_handler);
+ int i3 = stream1.async_shutdown(lazy);
+ (void)i3;
 
     stream1.write_some(buffer(mutable_char_buffer));
     stream1.write_some(buffer(const_char_buffer));
@@ -123,11 +131,17 @@
 
     stream1.async_write_some(buffer(mutable_char_buffer), write_some_handler);
     stream1.async_write_some(buffer(const_char_buffer), write_some_handler);
+ int i4 = stream1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i4;
+ int i5 = stream1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i5;
 
     stream1.read_some(buffer(mutable_char_buffer));
     stream1.read_some(buffer(mutable_char_buffer), ec);
 
     stream1.async_read_some(buffer(mutable_char_buffer), read_some_handler);
+ int i6 = stream1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i6;
 
 #if defined(BOOST_ASIO_ENABLE_OLD_SSL)
     stream1.peek(buffer(mutable_char_buffer));

Modified: trunk/libs/asio/test/windows/object_handle.cpp
==============================================================================
--- trunk/libs/asio/test/windows/object_handle.cpp (original)
+++ trunk/libs/asio/test/windows/object_handle.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 #include <boost/asio/windows/object_handle.hpp>
 
 #include <boost/asio/io_service.hpp>
+#include "../archetypes/async_result.hpp"
 #include "../unit_test.hpp"
 
 //------------------------------------------------------------------------------
@@ -42,6 +43,7 @@
   try
   {
     io_service ios;
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
 
     // basic_object_handle constructors.
@@ -99,6 +101,8 @@
     handle1.wait(ec);
 
     handle1.async_wait(&wait_handler);
+ int i1 = handle1.async_wait(lazy);
+ (void)i1;
   }
   catch (std::exception&)
   {

Modified: trunk/libs/asio/test/windows/random_access_handle.cpp
==============================================================================
--- trunk/libs/asio/test/windows/random_access_handle.cpp (original)
+++ trunk/libs/asio/test/windows/random_access_handle.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 #include <boost/asio/windows/random_access_handle.hpp>
 
 #include <boost/asio/io_service.hpp>
+#include "../archetypes/async_result.hpp"
 #include "../unit_test.hpp"
 
 //------------------------------------------------------------------------------
@@ -49,6 +50,7 @@
     char mutable_char_buffer[128] = "";
     const char const_char_buffer[128] = "";
     boost::uint64_t offset = 0;
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
 
     // basic_random_access_handle constructors.
@@ -114,12 +116,21 @@
         buffer(mutable_char_buffer), &write_some_handler);
     handle1.async_write_some_at(offset,
         buffer(const_char_buffer), &write_some_handler);
+ int i1 = handle1.async_write_some_at(offset,
+ buffer(mutable_char_buffer), lazy);
+ (void)i1;
+ int i2 = handle1.async_write_some_at(offset,
+ buffer(const_char_buffer), lazy);
+ (void)i2;
 
     handle1.read_some_at(offset, buffer(mutable_char_buffer));
     handle1.read_some_at(offset, buffer(mutable_char_buffer), ec);
 
     handle1.async_read_some_at(offset,
         buffer(mutable_char_buffer), &read_some_handler);
+ int i3 = handle1.async_read_some_at(offset,
+ buffer(mutable_char_buffer), lazy);
+ (void)i3;
   }
   catch (std::exception&)
   {

Modified: trunk/libs/asio/test/windows/stream_handle.cpp
==============================================================================
--- trunk/libs/asio/test/windows/stream_handle.cpp (original)
+++ trunk/libs/asio/test/windows/stream_handle.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -17,6 +17,7 @@
 #include <boost/asio/windows/stream_handle.hpp>
 
 #include <boost/asio/io_service.hpp>
+#include "../archetypes/async_result.hpp"
 #include "../unit_test.hpp"
 
 //------------------------------------------------------------------------------
@@ -48,6 +49,7 @@
     io_service ios;
     char mutable_char_buffer[128] = "";
     const char const_char_buffer[128] = "";
+ archetypes::lazy_handler lazy;
     boost::system::error_code ec;
 
     // basic_stream_handle constructors.
@@ -111,11 +113,17 @@
 
     handle1.async_write_some(buffer(mutable_char_buffer), &write_some_handler);
     handle1.async_write_some(buffer(const_char_buffer), &write_some_handler);
+ int i1 = handle1.async_write_some(buffer(mutable_char_buffer), lazy);
+ (void)i1;
+ int i2 = handle1.async_write_some(buffer(const_char_buffer), lazy);
+ (void)i2;
 
     handle1.read_some(buffer(mutable_char_buffer));
     handle1.read_some(buffer(mutable_char_buffer), ec);
 
     handle1.async_read_some(buffer(mutable_char_buffer), &read_some_handler);
+ int i3 = handle1.async_read_some(buffer(mutable_char_buffer), lazy);
+ (void)i3;
   }
   catch (std::exception&)
   {

Modified: trunk/libs/asio/test/write.cpp
==============================================================================
--- trunk/libs/asio/test/write.cpp (original)
+++ trunk/libs/asio/test/write.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -24,8 +24,10 @@
 #include <boost/noncopyable.hpp>
 #include <cstring>
 #include <vector>
+#include "archetypes/async_result.hpp"
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/placeholders.hpp>
+#include <boost/asio/streambuf.hpp>
 #include "unit_test.hpp"
 
 using namespace std; // For memcmp, memcpy and memset.
@@ -1636,6 +1638,13 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
 void test_3_arg_mutable_buffers_1_async_write()
@@ -1682,6 +1691,13 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
 }
 
 void test_3_arg_boost_array_buffers_async_write()
@@ -1729,6 +1745,13 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
 void test_3_arg_std_array_buffers_async_write()
@@ -1777,6 +1800,13 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
 }
 
@@ -1825,6 +1855,75 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_3_arg_streambuf_async_write()
+{
+ boost::asio::io_service ios;
+ test_stream s(ios);
+ boost::asio::streambuf sb;
+ boost::asio::const_buffers_1 buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ bool called = false;
+ boost::asio::async_write(s, sb,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ int i = boost::asio::async_write(s, sb, archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
 void test_4_arg_const_buffers_1_async_write()
@@ -2175,6 +2274,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
 void test_4_arg_mutable_buffers_1_async_write()
@@ -2525,6 +2632,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
 void test_4_arg_boost_array_buffers_async_write()
@@ -2876,6 +2991,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
 void test_4_arg_std_array_buffers_async_write()
@@ -3228,6 +3351,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
 }
 
@@ -3580,6 +3711,429 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write(s, buffers, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+}
+
+void test_4_arg_streambuf_async_write()
+{
+ boost::asio::io_service ios;
+ test_stream s(ios);
+ boost::asio::streambuf sb;
+ boost::asio::const_buffers_1 buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ bool called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_all(),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_all(),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_all(),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_at_least(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 50, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 50));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, boost::asio::transfer_exactly(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, old_style_transfer_all,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, old_style_transfer_all,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, old_style_transfer_all,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write(s, sb, short_transfer,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write(s, sb, short_transfer,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write(s, sb, short_transfer,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ int i = boost::asio::async_write(s, sb, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(buffers, sizeof(write_data)));
 }
 
 test_suite* init_unit_test_suite(int, char*[])
@@ -3604,10 +4158,12 @@
   test->add(BOOST_TEST_CASE(&test_3_arg_boost_array_buffers_async_write));
   test->add(BOOST_TEST_CASE(&test_3_arg_std_array_buffers_async_write));
   test->add(BOOST_TEST_CASE(&test_3_arg_vector_buffers_async_write));
+ test->add(BOOST_TEST_CASE(&test_3_arg_streambuf_async_write));
   test->add(BOOST_TEST_CASE(&test_4_arg_const_buffers_1_async_write));
   test->add(BOOST_TEST_CASE(&test_4_arg_mutable_buffers_1_async_write));
   test->add(BOOST_TEST_CASE(&test_4_arg_boost_array_buffers_async_write));
   test->add(BOOST_TEST_CASE(&test_4_arg_std_array_buffers_async_write));
   test->add(BOOST_TEST_CASE(&test_4_arg_vector_buffers_async_write));
+ test->add(BOOST_TEST_CASE(&test_4_arg_streambuf_async_write));
   return test;
 }

Modified: trunk/libs/asio/test/write_at.cpp
==============================================================================
--- trunk/libs/asio/test/write_at.cpp (original)
+++ trunk/libs/asio/test/write_at.cpp 2013-05-16 19:26:04 EDT (Thu, 16 May 2013)
@@ -23,8 +23,10 @@
 #include <boost/bind.hpp>
 #include <boost/noncopyable.hpp>
 #include <cstring>
+#include "archetypes/async_result.hpp"
 #include <boost/asio/io_service.hpp>
 #include <boost/asio/placeholders.hpp>
+#include <boost/asio/streambuf.hpp>
 #include "unit_test.hpp"
 
 using namespace std; // For memcmp, memcpy and memset.
@@ -2999,6 +3001,7 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
   s.reset();
   s.next_write_length(10);
   called = false;
@@ -3011,6 +3014,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
 }
 
 void test_4_arg_mutable_buffers_1_async_write_at()
@@ -3095,6 +3106,7 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
   s.reset();
   s.next_write_length(10);
   called = false;
@@ -3107,6 +3119,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(0, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
 }
 
 void test_4_arg_boost_array_buffers_async_write_at()
@@ -3192,6 +3212,7 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
   s.reset();
   s.next_write_length(10);
   called = false;
@@ -3204,6 +3225,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
 }
 
 void test_4_arg_std_array_buffers_async_write_at()
@@ -3290,6 +3319,7 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
   s.reset();
   s.next_write_length(10);
   called = false;
@@ -3302,6 +3332,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
 }
 
@@ -3388,6 +3426,7 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
   s.reset();
   s.next_write_length(10);
   called = false;
@@ -3400,6 +3439,136 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+}
+
+void test_4_arg_streambuf_async_write_at()
+{
+ boost::asio::io_service ios;
+ test_random_access_device s(ios);
+ boost::asio::streambuf sb;
+ boost::asio::const_buffers_1 buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ bool called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ int i = boost::asio::async_write_at(s, 0, sb,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
 }
 
 void test_5_arg_const_buffers_1_async_write_at()
@@ -4134,6 +4303,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
 }
 
 void test_5_arg_mutable_buffers_1_async_write_at()
@@ -4868,6 +5045,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(mutable_write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
 }
 
 void test_5_arg_boost_array_buffers_async_write_at()
@@ -5603,6 +5788,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
 }
 
 void test_5_arg_std_array_buffers_async_write_at()
@@ -6339,6 +6532,14 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
 #endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
 }
 
@@ -7075,6 +7276,867 @@
   ios.run();
   BOOST_CHECK(called);
   BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ int i = boost::asio::async_write_at(s, 0, buffers, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+}
+
+void test_5_arg_streambuf_async_write_at()
+{
+ boost::asio::io_service ios;
+ test_random_access_device s(ios);
+ boost::asio::streambuf sb;
+ boost::asio::const_buffers_1 buffers
+ = boost::asio::buffer(write_data, sizeof(write_data));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ bool called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_all(),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_all(),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_all(),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_all(),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_all(),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_all(),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_at_least(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 50, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 50));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_at_least(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 50, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 50));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(1),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 1, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 1));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(10),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 10, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 10));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb,
+ boost::asio::transfer_exactly(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb,
+ boost::asio::transfer_exactly(42),
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ 42, &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, 42));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, old_style_transfer_all,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, old_style_transfer_all,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, old_style_transfer_all,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, old_style_transfer_all,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, old_style_transfer_all,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, old_style_transfer_all,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, short_transfer,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, short_transfer,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, short_transfer,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(1);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, short_transfer,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 0, sb, short_transfer,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ s.next_write_length(10);
+ called = false;
+ boost::asio::async_write_at(s, 1234, sb, short_transfer,
+ boost::bind(async_write_handler,
+ boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred,
+ sizeof(write_data), &called));
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(called);
+ BOOST_CHECK(s.check_buffers(1234, buffers, sizeof(write_data)));
+
+ s.reset();
+ sb.consume(sb.size());
+ sb.sputn(write_data, sizeof(write_data));
+ int i = boost::asio::async_write_at(s, 0, sb, short_transfer,
+ archetypes::lazy_handler());
+ BOOST_CHECK(i == 42);
+ ios.reset();
+ ios.run();
+ BOOST_CHECK(s.check_buffers(0, buffers, sizeof(write_data)));
 }
 
 test_suite* init_unit_test_suite(int, char*[])
@@ -7097,10 +8159,12 @@
   test->add(BOOST_TEST_CASE(&test_4_arg_boost_array_buffers_async_write_at));
   test->add(BOOST_TEST_CASE(&test_4_arg_std_array_buffers_async_write_at));
   test->add(BOOST_TEST_CASE(&test_4_arg_vector_buffers_async_write_at));
+ test->add(BOOST_TEST_CASE(&test_4_arg_streambuf_async_write_at));
   test->add(BOOST_TEST_CASE(&test_5_arg_const_buffers_1_async_write_at));
   test->add(BOOST_TEST_CASE(&test_5_arg_mutable_buffers_1_async_write_at));
   test->add(BOOST_TEST_CASE(&test_5_arg_boost_array_buffers_async_write_at));
   test->add(BOOST_TEST_CASE(&test_5_arg_std_array_buffers_async_write_at));
   test->add(BOOST_TEST_CASE(&test_5_arg_vector_buffers_async_write_at));
+ test->add(BOOST_TEST_CASE(&test_5_arg_streambuf_async_write_at));
   return test;
 }


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk