]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/asio/defer.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / asio / defer.hpp
index 2eaf2d01c667565f4dc9e2be1409ee7cfebbded7..7967f9dc637d25964cb6917bb73efcde8bc17600 100644 (file)
@@ -2,7 +2,7 @@
 // defer.hpp
 // ~~~~~~~~~
 //
-// Copyright (c) 2003-2018 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2020 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)
@@ -19,6 +19,7 @@
 #include <boost/asio/async_result.hpp>
 #include <boost/asio/detail/type_traits.hpp>
 #include <boost/asio/execution_context.hpp>
+#include <boost/asio/execution/executor.hpp>
 #include <boost/asio/is_executor.hpp>
 
 #include <boost/asio/detail/push_options.hpp>
@@ -32,6 +33,11 @@ namespace asio {
  * executor. The function object is queued for execution, and is never called
  * from the current thread prior to returning from <tt>defer()</tt>.
  *
+ * The use of @c defer(), rather than @ref post(), indicates the caller's
+ * preference that the executor defer the queueing of the function object. This
+ * may allow the executor to optimise queueing for cases when the function
+ * object represents a continuation of the current call context.
+ *
  * This function has the following effects:
  *
  * @li Constructs a function object handler of type @c Handler, initialized
@@ -50,8 +56,8 @@ namespace asio {
  *
  * @li Returns <tt>result.get()</tt>.
  */
-template <typename CompletionToken>
-BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer(
+template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken>
+BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) defer(
     BOOST_ASIO_MOVE_ARG(CompletionToken) token);
 
 /// Submits a completion token or function object for execution.
@@ -60,6 +66,11 @@ BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer(
  * The function object is queued for execution, and is never called from the
  * current thread prior to returning from <tt>defer()</tt>.
  *
+ * The use of @c defer(), rather than @ref post(), indicates the caller's
+ * preference that the executor defer the queueing of the function object. This
+ * may allow the executor to optimise queueing for cases when the function
+ * object represents a continuation of the current call context.
+ *
  * This function has the following effects:
  *
  * @li Constructs a function object handler of type @c Handler, initialized
@@ -84,18 +95,30 @@ BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer(
  *
  * @li Returns <tt>result.get()</tt>.
  */
-template <typename Executor, typename CompletionToken>
-BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer(
-    const Executor& ex, BOOST_ASIO_MOVE_ARG(CompletionToken) token,
-    typename enable_if<is_executor<Executor>::value>::type* = 0);
+template <typename Executor,
+    BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken
+      BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)>
+BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) defer(
+    const Executor& ex,
+    BOOST_ASIO_MOVE_ARG(CompletionToken) token
+      BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor),
+    typename enable_if<
+      execution::is_executor<Executor>::value || is_executor<Executor>::value
+    >::type* = 0);
 
 /// Submits a completion token or function object for execution.
 /**
  * @returns <tt>defer(ctx.get_executor(), forward<CompletionToken>(token))</tt>.
  */
-template <typename ExecutionContext, typename CompletionToken>
-BOOST_ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer(
-    ExecutionContext& ctx, BOOST_ASIO_MOVE_ARG(CompletionToken) token,
+template <typename ExecutionContext,
+    BOOST_ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken
+      BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(
+        typename ExecutionContext::executor_type)>
+BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) defer(
+    ExecutionContext& ctx,
+    BOOST_ASIO_MOVE_ARG(CompletionToken) token
+      BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(
+        typename ExecutionContext::executor_type),
     typename enable_if<is_convertible<
       ExecutionContext&, execution_context&>::value>::type* = 0);