boost/cobalt/spawn.hpp – 1.87.0

boost/cobalt/spawn.hpp

//
// Copyright (c) 2022 Klemens Morgenstern ([email protected])
//
// 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)
//

#ifndef BOOST_COBALT_SPAWN_HPP
#define BOOST_COBALT_SPAWN_HPP

#include <boost/cobalt/detail/spawn.hpp>

namespace boost::cobalt
{

template
auto spawn(Context & context,
           task && t,
           CompletionToken&& token)
{
    return asio::async_initiate(
            detail::async_initiate_spawn{context.get_executor()}, token, std::move(t));
}

template<:convertible_to> Executor, typename T, typename CompletionToken>
auto spawn(Executor executor, task && t,
           CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor))
{
    return asio::async_initiate(
            detail::async_initiate_spawn{executor}, token, std::move(t));
}

template
auto spawn(Context & context,
           task && t,
           CompletionToken&& token)
{
    return asio::async_initiate(
            detail::async_initiate_spawn{context.get_executor()}, token, std::move(t));
}

template<:convertible_to> Executor, typename CompletionToken>
auto spawn(Executor executor, task && t,
           CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor))
{
    return asio::async_initiate(
            detail::async_initiate_spawn{executor}, token, std::move(t));

}

}

#endif //BOOST_COBALT_SPAWN_HPP

Read more here: Source link