// impl/spawn.hpp
// ~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2022 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)
}
};
-template <typename Handler, typename T, typename Allocator>
-struct associated_allocator<detail::coro_handler<Handler, T>, Allocator>
+template <template <typename, typename> class Associator,
+ typename Handler, typename T, typename DefaultCandidate>
+struct associator<Associator,
+ detail::coro_handler<Handler, T>,
+ DefaultCandidate>
+ : Associator<Handler, DefaultCandidate>
{
- typedef typename associated_allocator<Handler, Allocator>::type type;
-
- static type get(const detail::coro_handler<Handler, T>& h,
- const Allocator& a = Allocator()) BOOST_ASIO_NOEXCEPT
- {
- return associated_allocator<Handler, Allocator>::get(h.handler_, a);
- }
-};
-
-template <typename Handler, typename T, typename Executor>
-struct associated_executor<detail::coro_handler<Handler, T>, Executor>
- : detail::associated_executor_forwarding_base<Handler, Executor>
-{
- typedef typename associated_executor<Handler, Executor>::type type;
-
- static type get(const detail::coro_handler<Handler, T>& h,
- const Executor& ex = Executor()) BOOST_ASIO_NOEXCEPT
+ static typename Associator<Handler, DefaultCandidate>::type get(
+ const detail::coro_handler<Handler, T>& h,
+ const DefaultCandidate& c = DefaultCandidate()) BOOST_ASIO_NOEXCEPT
{
- return associated_executor<Handler, Executor>::get(h.handler_, ex);
+ return Associator<Handler, DefaultCandidate>::get(h.handler_, c);
}
};
(data->function_)(yield);
if (data->call_handler_)
- (data->handler_)();
+ BOOST_ASIO_MOVE_OR_LVALUE(Handler)(data->handler_)();
}
shared_ptr<spawn_data<Handler, Function> > data_;
void spawn(BOOST_ASIO_MOVE_ARG(Handler) handler,
BOOST_ASIO_MOVE_ARG(Function) function,
const boost::coroutines::attributes& attributes,
- typename enable_if<
+ typename constraint<
!is_executor<typename decay<Handler>::type>::value &&
!execution::is_executor<typename decay<Handler>::type>::value &&
- !is_convertible<Handler&, execution_context&>::value>::type*)
+ !is_convertible<Handler&, execution_context&>::value>::type)
{
typedef typename decay<Handler>::type handler_type;
typedef typename decay<Function>::type function_type;
inline void spawn(const Executor& ex,
BOOST_ASIO_MOVE_ARG(Function) function,
const boost::coroutines::attributes& attributes,
- typename enable_if<
+ typename constraint<
is_executor<Executor>::value || execution::is_executor<Executor>::value
- >::type*)
+ >::type)
{
boost::asio::spawn(boost::asio::strand<Executor>(ex),
BOOST_ASIO_MOVE_CAST(Function)(function), attributes);
inline void spawn(ExecutionContext& ctx,
BOOST_ASIO_MOVE_ARG(Function) function,
const boost::coroutines::attributes& attributes,
- typename enable_if<is_convertible<
- ExecutionContext&, execution_context&>::value>::type*)
+ typename constraint<is_convertible<
+ ExecutionContext&, execution_context&>::value>::type)
{
boost::asio::spawn(ctx.get_executor(),
BOOST_ASIO_MOVE_CAST(Function)(function), attributes);