| 1 |
|
|
1 |
|
|
| 2 |
|
// Copyright (c) 2026 Vinnie Falco (vinnie.falco@gmail.com)
|
2 |
|
// Copyright (c) 2026 Vinnie Falco (vinnie.falco@gmail.com)
|
| 3 |
|
// Copyright (c) 2026 Steve Gerbino
|
3 |
|
// Copyright (c) 2026 Steve Gerbino
|
| 4 |
|
|
4 |
|
|
| 5 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
5 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
| 6 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
6 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 7 |
|
|
7 |
|
|
| 8 |
|
// Official repository: https://github.com/cppalliance/corosio
|
8 |
|
// Official repository: https://github.com/cppalliance/corosio
|
| 9 |
|
|
9 |
|
|
| 10 |
|
|
10 |
|
|
| 11 |
|
#ifndef BOOST_COROSIO_DETAIL_DISPATCH_CORO_HPP
|
11 |
|
#ifndef BOOST_COROSIO_DETAIL_DISPATCH_CORO_HPP
|
| 12 |
|
#define BOOST_COROSIO_DETAIL_DISPATCH_CORO_HPP
|
12 |
|
#define BOOST_COROSIO_DETAIL_DISPATCH_CORO_HPP
|
| 13 |
|
|
13 |
|
|
| 14 |
|
#include <boost/corosio/io_context.hpp>
|
14 |
|
#include <boost/corosio/io_context.hpp>
|
| 15 |
|
#include <boost/capy/ex/executor_ref.hpp>
|
15 |
|
#include <boost/capy/ex/executor_ref.hpp>
|
| 16 |
|
#include <boost/capy/detail/type_id.hpp>
|
16 |
|
#include <boost/capy/detail/type_id.hpp>
|
| 17 |
|
|
17 |
|
|
| 18 |
|
|
18 |
|
|
| 19 |
|
namespace boost::corosio::detail {
|
19 |
|
namespace boost::corosio::detail {
|
| 20 |
|
|
20 |
|
|
| 21 |
|
/** Returns a handle for symmetric transfer on I/O completion.
|
21 |
|
/** Returns a handle for symmetric transfer on I/O completion.
|
| 22 |
|
|
22 |
|
|
| 23 |
|
If the executor is io_context::executor_type, returns `h`
|
23 |
|
If the executor is io_context::executor_type, returns `h`
|
| 24 |
|
directly (fast path). Otherwise dispatches through the
|
24 |
|
directly (fast path). Otherwise dispatches through the
|
| 25 |
|
executor, which returns `h` or `noop_coroutine()`.
|
25 |
|
executor, which returns `h` or `noop_coroutine()`.
|
| 26 |
|
|
26 |
|
|
| 27 |
|
Callers in coroutine machinery should return the result
|
27 |
|
Callers in coroutine machinery should return the result
|
| 28 |
|
for symmetric transfer. Callers at the scheduler pump
|
28 |
|
for symmetric transfer. Callers at the scheduler pump
|
| 29 |
|
level should call `.resume()` on the result.
|
29 |
|
level should call `.resume()` on the result.
|
| 30 |
|
|
30 |
|
|
| 31 |
|
@param ex The executor to dispatch through.
|
31 |
|
@param ex The executor to dispatch through.
|
| 32 |
|
@param h The coroutine handle to resume.
|
32 |
|
@param h The coroutine handle to resume.
|
| 33 |
|
|
33 |
|
|
| 34 |
|
@return A handle for symmetric transfer or `std::noop_coroutine()`.
|
34 |
|
@return A handle for symmetric transfer or `std::noop_coroutine()`.
|
| 35 |
|
|
35 |
|
|
| 36 |
|
inline std::coroutine_handle<>
|
36 |
|
inline std::coroutine_handle<>
|
| 37 |
|
dispatch_coro(capy::executor_ref ex, std::coroutine_handle<> h)
|
37 |
|
dispatch_coro(capy::executor_ref ex, std::coroutine_handle<> h)
|
| 38 |
|
|
38 |
|
|
| 39 |
|
if (ex.target<io_context::executor_type>() != nullptr)
|
39 |
|
if (ex.target<io_context::executor_type>() != nullptr)
|
| 40 |
|
|
40 |
|
|
| 41 |
|
|
41 |
|
|
| 42 |
|
|
42 |
|
|
| 43 |
|
|
43 |
|
|
| 44 |
|
} // namespace boost::corosio::detail
|
44 |
|
} // namespace boost::corosio::detail
|
| 45 |
|
|
45 |
|
|
| 46 |
|
|
46 |
|
|