Track the underlying reactor operations associated with handlers.

For reactor-based platforms only. For example, an async send on a reactor-based
platform will now log the result to each non-blocking send system call.
diff --git a/asio/include/asio/detail/descriptor_read_op.hpp b/asio/include/asio/detail/descriptor_read_op.hpp
index caf9b63..db52b59 100644
--- a/asio/include/asio/detail/descriptor_read_op.hpp
+++ b/asio/include/asio/detail/descriptor_read_op.hpp
@@ -51,8 +51,13 @@
     buffer_sequence_adapter<asio::mutable_buffer,
         MutableBufferSequence> bufs(o->buffers_);
 
-    return descriptor_ops::non_blocking_read(o->descriptor_,
+    bool result = descriptor_ops::non_blocking_read(o->descriptor_,
         bufs.buffers(), bufs.count(), o->ec_, o->bytes_transferred_);
+
+    ASIO_HANDLER_REACTOR_OPERATION((*o, "non_blocking_read",
+          o->ec_, o->bytes_transferred_));
+
+    return result;
   }
 
 private:
diff --git a/asio/include/asio/detail/descriptor_write_op.hpp b/asio/include/asio/detail/descriptor_write_op.hpp
index 3157a08..ba18152 100644
--- a/asio/include/asio/detail/descriptor_write_op.hpp
+++ b/asio/include/asio/detail/descriptor_write_op.hpp
@@ -51,8 +51,13 @@
     buffer_sequence_adapter<asio::const_buffer,
         ConstBufferSequence> bufs(o->buffers_);
 
-    return descriptor_ops::non_blocking_write(o->descriptor_,
+    bool result = descriptor_ops::non_blocking_write(o->descriptor_,
         bufs.buffers(), bufs.count(), o->ec_, o->bytes_transferred_);
+
+    ASIO_HANDLER_REACTOR_OPERATION((*o, "non_blocking_write",
+          o->ec_, o->bytes_transferred_));
+
+    return result;
   }
 
 private:
diff --git a/asio/include/asio/detail/handler_tracking.hpp b/asio/include/asio/detail/handler_tracking.hpp
index 67533a5..e177f5f 100644
--- a/asio/include/asio/detail/handler_tracking.hpp
+++ b/asio/include/asio/detail/handler_tracking.hpp
@@ -44,6 +44,7 @@
 // - ASIO_HANDLER_INVOCATION_BEGIN(args)
 // - ASIO_HANDLER_INVOCATION_END
 // - ASIO_HANDLER_OPERATION(args)
+// - ASIO_HANDLER_REACTOR_OPERATION(args)
 
 #elif defined(ASIO_ENABLE_HANDLER_TRACKING)
 
@@ -116,11 +117,21 @@
     completion* next_;
   };
 
-  // Record an operation that affects pending handlers.
+  // Record an operation that is not directly associated with a handler.
   ASIO_DECL static void operation(execution_context& context,
       const char* object_type, void* object,
       uintmax_t native_handle, const char* op_name);
 
+  // Record a reactor-based operation that is associated with a handler.
+  ASIO_DECL static void reactor_operation(
+      const tracked_handler& h, const char* op_name,
+      const asio::error_code& ec);
+
+  // Record a reactor-based operation that is associated with a handler.
+  ASIO_DECL static void reactor_operation(
+      const tracked_handler& h, const char* op_name,
+      const asio::error_code& ec, std::size_t bytes_transferred);
+
   // Write a line of output.
   ASIO_DECL static void write_line(const char* format, ...);
 
@@ -153,6 +164,9 @@
 # define ASIO_HANDLER_OPERATION(args) \
   asio::detail::handler_tracking::operation args
 
+# define ASIO_HANDLER_REACTOR_OPERATION(args) \
+  asio::detail::handler_tracking::reactor_operation args
+
 #else // defined(ASIO_ENABLE_HANDLER_TRACKING)
 
 # define ASIO_INHERIT_TRACKED_HANDLER
@@ -163,6 +177,7 @@
 # define ASIO_HANDLER_INVOCATION_BEGIN(args) (void)0
 # define ASIO_HANDLER_INVOCATION_END (void)0
 # define ASIO_HANDLER_OPERATION(args) (void)0
+# define ASIO_HANDLER_REACTOR_OPERATION(args) (void)0
 
 #endif // defined(ASIO_ENABLE_HANDLER_TRACKING)
 
diff --git a/asio/include/asio/detail/impl/handler_tracking.ipp b/asio/include/asio/detail/impl/handler_tracking.ipp
index 93d329e..d3a1cad 100644
--- a/asio/include/asio/detail/impl/handler_tracking.ipp
+++ b/asio/include/asio/detail/impl/handler_tracking.ipp
@@ -278,6 +278,39 @@
       current_id, object_type, object, op_name);
 }
 
+void handler_tracking::reactor_operation(
+    const tracked_handler& h, const char* op_name,
+    const asio::error_code& ec)
+{
+  handler_tracking_timestamp timestamp;
+
+  write_line(
+#if defined(ASIO_WINDOWS)
+      "@asio|%I64u.%06I64u|.%I64u|%s,ec=%.20s:%d\n",
+#else // defined(ASIO_WINDOWS)
+      "@asio|%llu.%06llu|.%llu|%s,ec=%.20s:%d\n",
+#endif // defined(ASIO_WINDOWS)
+      timestamp.seconds, timestamp.microseconds,
+      h.id_, op_name, ec.category().name(), ec.value());
+}
+
+void handler_tracking::reactor_operation(
+    const tracked_handler& h, const char* op_name,
+    const asio::error_code& ec, std::size_t bytes_transferred)
+{
+  handler_tracking_timestamp timestamp;
+
+  write_line(
+#if defined(ASIO_WINDOWS)
+      "@asio|%I64u.%06I64u|.%I64u|%s,ec=%.20s:%d,bytes_transferred=%I64u\n",
+#else // defined(ASIO_WINDOWS)
+      "@asio|%llu.%06llu|.%llu|%s,ec=%.20s:%d,bytes_transferred=%llu\n",
+#endif // defined(ASIO_WINDOWS)
+      timestamp.seconds, timestamp.microseconds,
+      h.id_, op_name, ec.category().name(), ec.value(),
+      static_cast<uint64_t>(bytes_transferred));
+}
+
 void handler_tracking::write_line(const char* format, ...)
 {
   using namespace std; // For sprintf (or equivalent).
diff --git a/asio/include/asio/detail/reactive_socket_accept_op.hpp b/asio/include/asio/detail/reactive_socket_accept_op.hpp
index d94bf56..f71954e 100644
--- a/asio/include/asio/detail/reactive_socket_accept_op.hpp
+++ b/asio/include/asio/detail/reactive_socket_accept_op.hpp
@@ -56,6 +56,8 @@
           o->state_, o->peer_endpoint_ ? o->peer_endpoint_->data() : 0,
           o->peer_endpoint_ ? &addrlen : 0, o->ec_, new_socket);
 
+    ASIO_HANDLER_REACTOR_OPERATION((*o, "non_blocking_accept", o->ec_));
+
     // On success, assign new connection to peer socket object.
     if (new_socket != invalid_socket)
     {
diff --git a/asio/include/asio/detail/reactive_socket_connect_op.hpp b/asio/include/asio/detail/reactive_socket_connect_op.hpp
index a75a407..a3ef142 100644
--- a/asio/include/asio/detail/reactive_socket_connect_op.hpp
+++ b/asio/include/asio/detail/reactive_socket_connect_op.hpp
@@ -42,7 +42,11 @@
     reactive_socket_connect_op_base* o(
         static_cast<reactive_socket_connect_op_base*>(base));
 
-    return socket_ops::non_blocking_connect(o->socket_, o->ec_);
+    bool result = socket_ops::non_blocking_connect(o->socket_, o->ec_);
+
+    ASIO_HANDLER_REACTOR_OPERATION((*o, "non_blocking_connect", o->ec_));
+
+    return result;
   }
 
 private:
diff --git a/asio/include/asio/detail/reactive_socket_recv_op.hpp b/asio/include/asio/detail/reactive_socket_recv_op.hpp
index dd0f254..4d737cb 100644
--- a/asio/include/asio/detail/reactive_socket_recv_op.hpp
+++ b/asio/include/asio/detail/reactive_socket_recv_op.hpp
@@ -51,10 +51,15 @@
     buffer_sequence_adapter<asio::mutable_buffer,
         MutableBufferSequence> bufs(o->buffers_);
 
-    return socket_ops::non_blocking_recv(o->socket_,
+    bool result = socket_ops::non_blocking_recv(o->socket_,
         bufs.buffers(), bufs.count(), o->flags_,
         (o->state_ & socket_ops::stream_oriented) != 0,
         o->ec_, o->bytes_transferred_);
+
+    ASIO_HANDLER_REACTOR_OPERATION((*o, "non_blocking_recv",
+          o->ec_, o->bytes_transferred_));
+
+    return result;
   }
 
 private:
diff --git a/asio/include/asio/detail/reactive_socket_recvfrom_op.hpp b/asio/include/asio/detail/reactive_socket_recvfrom_op.hpp
index 56ab32d..3f69b38 100644
--- a/asio/include/asio/detail/reactive_socket_recvfrom_op.hpp
+++ b/asio/include/asio/detail/reactive_socket_recvfrom_op.hpp
@@ -61,6 +61,9 @@
     if (result && !o->ec_)
       o->sender_endpoint_.resize(addr_len);
 
+    ASIO_HANDLER_REACTOR_OPERATION((*o, "non_blocking_recvfrom",
+          o->ec_, o->bytes_transferred_));
+
     return result;
   }
 
diff --git a/asio/include/asio/detail/reactive_socket_recvmsg_op.hpp b/asio/include/asio/detail/reactive_socket_recvmsg_op.hpp
index e174940..8cc37ff 100644
--- a/asio/include/asio/detail/reactive_socket_recvmsg_op.hpp
+++ b/asio/include/asio/detail/reactive_socket_recvmsg_op.hpp
@@ -52,10 +52,15 @@
     buffer_sequence_adapter<asio::mutable_buffer,
         MutableBufferSequence> bufs(o->buffers_);
 
-    return socket_ops::non_blocking_recvmsg(o->socket_,
+    bool result = socket_ops::non_blocking_recvmsg(o->socket_,
         bufs.buffers(), bufs.count(),
         o->in_flags_, o->out_flags_,
         o->ec_, o->bytes_transferred_);
+
+    ASIO_HANDLER_REACTOR_OPERATION((*o, "non_blocking_recvmsg",
+          o->ec_, o->bytes_transferred_));
+
+    return result;
   }
 
 private:
diff --git a/asio/include/asio/detail/reactive_socket_send_op.hpp b/asio/include/asio/detail/reactive_socket_send_op.hpp
index ed4e587..338446d 100644
--- a/asio/include/asio/detail/reactive_socket_send_op.hpp
+++ b/asio/include/asio/detail/reactive_socket_send_op.hpp
@@ -50,9 +50,14 @@
     buffer_sequence_adapter<asio::const_buffer,
         ConstBufferSequence> bufs(o->buffers_);
 
-    return socket_ops::non_blocking_send(o->socket_,
+    bool result = socket_ops::non_blocking_send(o->socket_,
           bufs.buffers(), bufs.count(), o->flags_,
           o->ec_, o->bytes_transferred_);
+
+    ASIO_HANDLER_REACTOR_OPERATION((*o, "non_blocking_send",
+          o->ec_, o->bytes_transferred_));
+
+    return result;
   }
 
 private:
diff --git a/asio/include/asio/detail/reactive_socket_sendto_op.hpp b/asio/include/asio/detail/reactive_socket_sendto_op.hpp
index 9780716..48d4455 100644
--- a/asio/include/asio/detail/reactive_socket_sendto_op.hpp
+++ b/asio/include/asio/detail/reactive_socket_sendto_op.hpp
@@ -51,10 +51,15 @@
     buffer_sequence_adapter<asio::const_buffer,
         ConstBufferSequence> bufs(o->buffers_);
 
-    return socket_ops::non_blocking_sendto(o->socket_,
+    bool result = socket_ops::non_blocking_sendto(o->socket_,
           bufs.buffers(), bufs.count(), o->flags_,
           o->destination_.data(), o->destination_.size(),
           o->ec_, o->bytes_transferred_);
+
+    ASIO_HANDLER_REACTOR_OPERATION((*o, "non_blocking_sendto",
+          o->ec_, o->bytes_transferred_));
+
+    return result;
   }
 
 private: