X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Fboost%2Fasio%2Fimpl%2Fdefer.hpp;h=71f6a8828ea720427163cf3ece9a486a452f0b04;hb=20effc670b57271cb089376d6d0800990e5218d5;hp=d507eb1231cd77fba250a72acc7a98c59dbe9a1b;hpb=92f5a8d42d07f9929ae4fa7e01342fe8d96808a8;p=ceph.git diff --git a/ceph/src/boost/boost/asio/impl/defer.hpp b/ceph/src/boost/boost/asio/impl/defer.hpp index d507eb123..71f6a8828 100644 --- a/ceph/src/boost/boost/asio/impl/defer.hpp +++ b/ceph/src/boost/boost/asio/impl/defer.hpp @@ -2,7 +2,7 @@ // impl/defer.hpp // ~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2019 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,11 @@ #include #include #include +#include +#include +#include +#include +#include #include @@ -30,14 +35,47 @@ class initiate_defer { public: template - void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler) const + void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler, + typename enable_if< + execution::is_executor< + typename associated_executor< + typename decay::type + >::type + >::value + >::type* = 0) const { - typedef typename decay::type DecayedHandler; + typedef typename decay::type handler_t; - typename associated_executor::type ex( + typename associated_executor::type ex( (get_associated_executor)(handler)); - typename associated_allocator::type alloc( + typename associated_allocator::type alloc( + (get_associated_allocator)(handler)); + + execution::execute( + boost::asio::prefer( + boost::asio::require(ex, execution::blocking.never), + execution::relationship.continuation, + execution::allocator(alloc)), + BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)); + } + + template + void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler, + typename enable_if< + !execution::is_executor< + typename associated_executor< + typename decay::type + >::type + >::value + >::type* = 0) const + { + typedef typename decay::type handler_t; + + typename associated_executor::type ex( + (get_associated_executor)(handler)); + + typename associated_allocator::type alloc( (get_associated_allocator)(handler)); ex.defer(BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), alloc); @@ -61,15 +99,108 @@ public: } template - void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler) const + void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler, + typename enable_if< + execution::is_executor< + typename conditional::type + >::value + && + !detail::is_work_dispatcher_required< + typename decay::type, + Executor + >::value + >::type* = 0) const { - typedef typename decay::type DecayedHandler; + typedef typename decay::type handler_t; + + typename associated_allocator::type alloc( + (get_associated_allocator)(handler)); + + execution::execute( + boost::asio::prefer( + boost::asio::require(ex_, execution::blocking.never), + execution::relationship.continuation, + execution::allocator(alloc)), + BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)); + } + + template + void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler, + typename enable_if< + execution::is_executor< + typename conditional::type + >::value + && + detail::is_work_dispatcher_required< + typename decay::type, + Executor + >::value + >::type* = 0) const + { + typedef typename decay::type handler_t; + + typedef typename associated_executor< + handler_t, Executor>::type handler_ex_t; + handler_ex_t handler_ex((get_associated_executor)(handler, ex_)); - typename associated_allocator::type alloc( + typename associated_allocator::type alloc( (get_associated_allocator)(handler)); - ex_.defer(detail::work_dispatcher( - BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler)), alloc); + execution::execute( + boost::asio::prefer( + boost::asio::require(ex_, execution::blocking.never), + execution::relationship.continuation, + execution::allocator(alloc)), + detail::work_dispatcher( + BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), handler_ex)); + } + + template + void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler, + typename enable_if< + !execution::is_executor< + typename conditional::type + >::value + && + !detail::is_work_dispatcher_required< + typename decay::type, + Executor + >::value + >::type* = 0) const + { + typedef typename decay::type handler_t; + + typename associated_allocator::type alloc( + (get_associated_allocator)(handler)); + + ex_.defer(BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), alloc); + } + + template + void operator()(BOOST_ASIO_MOVE_ARG(CompletionHandler) handler, + typename enable_if< + !execution::is_executor< + typename conditional::type + >::value + && + detail::is_work_dispatcher_required< + typename decay::type, + Executor + >::value + >::type* = 0) const + { + typedef typename decay::type handler_t; + + typedef typename associated_executor< + handler_t, Executor>::type handler_ex_t; + handler_ex_t handler_ex((get_associated_executor)(handler, ex_)); + + typename associated_allocator::type alloc( + (get_associated_allocator)(handler)); + + ex_.defer(detail::work_dispatcher( + BOOST_ASIO_MOVE_CAST(CompletionHandler)(handler), + handler_ex), alloc); } private: @@ -90,7 +221,9 @@ template BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) defer( const Executor& ex, BOOST_ASIO_MOVE_ARG(CompletionToken) token, - typename enable_if::value>::type*) + typename enable_if< + execution::is_executor::value || is_executor::value + >::type*) { return async_initiate( detail::initiate_defer_with_executor(ex), token); @@ -103,8 +236,10 @@ inline BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void()) defer( typename enable_if::value>::type*) { - return (defer)(ctx.get_executor(), - BOOST_ASIO_MOVE_CAST(CompletionToken)(token)); + return async_initiate( + detail::initiate_defer_with_executor< + typename ExecutionContext::executor_type>( + ctx.get_executor()), token); } } // namespace asio