diff options
Diffstat (limited to '3rdparty/asio/include/asio/defer.hpp')
-rw-r--r-- | 3rdparty/asio/include/asio/defer.hpp | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/3rdparty/asio/include/asio/defer.hpp b/3rdparty/asio/include/asio/defer.hpp index 5e8061406ab..b0829e83848 100644 --- a/3rdparty/asio/include/asio/defer.hpp +++ b/3rdparty/asio/include/asio/defer.hpp @@ -2,7 +2,7 @@ // defer.hpp // ~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2021 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 "asio/async_result.hpp" #include "asio/detail/type_traits.hpp" #include "asio/execution_context.hpp" +#include "asio/execution/executor.hpp" #include "asio/is_executor.hpp" #include "asio/detail/push_options.hpp" @@ -31,6 +32,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 @@ -49,8 +55,8 @@ namespace asio { * * @li Returns <tt>result.get()</tt>. */ -template <typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer( +template <ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken> +ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) defer( ASIO_MOVE_ARG(CompletionToken) token); /// Submits a completion token or function object for execution. @@ -59,6 +65,11 @@ 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 @@ -83,20 +94,32 @@ ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer( * * @li Returns <tt>result.get()</tt>. */ -template <typename Executor, typename CompletionToken> -ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer( - const Executor& ex, ASIO_MOVE_ARG(CompletionToken) token, - typename enable_if<is_executor<Executor>::value>::type* = 0); +template <typename Executor, + ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken + ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)> +ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) defer( + const Executor& ex, + ASIO_MOVE_ARG(CompletionToken) token + ASIO_DEFAULT_COMPLETION_TOKEN(Executor), + typename constraint< + 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> -ASIO_INITFN_RESULT_TYPE(CompletionToken, void()) defer( - ExecutionContext& ctx, ASIO_MOVE_ARG(CompletionToken) token, - typename enable_if<is_convertible< - ExecutionContext&, execution_context&>::value>::type* = 0); +template <typename ExecutionContext, + ASIO_COMPLETION_TOKEN_FOR(void()) CompletionToken + ASIO_DEFAULT_COMPLETION_TOKEN_TYPE( + typename ExecutionContext::executor_type)> +ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) defer( + ExecutionContext& ctx, + ASIO_MOVE_ARG(CompletionToken) token + ASIO_DEFAULT_COMPLETION_TOKEN( + typename ExecutionContext::executor_type), + typename constraint<is_convertible< + ExecutionContext&, execution_context&>::value>::type = 0); } // namespace asio |