File indexing completed on 2025-12-16 09:44:27
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_COBALT_SPAWN_HPP
0009 #define BOOST_COBALT_SPAWN_HPP
0010
0011 #include <boost/cobalt/detail/spawn.hpp>
0012
0013 namespace boost::cobalt
0014 {
0015
0016 template<with_get_executor Context, typename T, typename CompletionToken>
0017 auto spawn(Context & context,
0018 task<T> && t,
0019 CompletionToken&& token)
0020 {
0021 return asio::async_initiate<CompletionToken, void(std::exception_ptr, T)>(
0022 detail::async_initiate_spawn{context.get_executor()}, token, std::move(t));
0023 }
0024
0025 template<std::convertible_to<executor> Executor, typename T, typename CompletionToken>
0026 auto spawn(Executor executor, task<T> && t,
0027 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor))
0028 {
0029 return asio::async_initiate<CompletionToken, void(std::exception_ptr, T)>(
0030 detail::async_initiate_spawn{executor}, token, std::move(t));
0031 }
0032
0033 template<with_get_executor Context, typename CompletionToken>
0034 auto spawn(Context & context,
0035 task<void> && t,
0036 CompletionToken&& token)
0037 {
0038 return asio::async_initiate<CompletionToken, void(std::exception_ptr)>(
0039 detail::async_initiate_spawn{context.get_executor()}, token, std::move(t));
0040 }
0041
0042 template<std::convertible_to<executor> Executor, typename CompletionToken>
0043 auto spawn(Executor executor, task<void> && t,
0044 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor))
0045 {
0046 return asio::async_initiate<CompletionToken, void(std::exception_ptr)>(
0047 detail::async_initiate_spawn{executor}, token, std::move(t));
0048
0049 }
0050
0051 }
0052
0053 #endif