libs/corosio/src/corosio/src/detail/resume_coro.hpp
80.0% Lines (4/5)
100.0% Functions (1/1)
50.0% Branches (1/2)
libs/corosio/src/corosio/src/detail/resume_coro.hpp
| Line | Branch | Hits | Source Code |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2026 Vinnie Falco (vinnie dot falco at gmail dot com) | ||
| 3 | // | ||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| 6 | // | ||
| 7 | // Official repository: https://github.com/cppalliance/corosio | ||
| 8 | // | ||
| 9 | |||
| 10 | #ifndef BOOST_COROSIO_DETAIL_RESUME_CORO_HPP | ||
| 11 | #define BOOST_COROSIO_DETAIL_RESUME_CORO_HPP | ||
| 12 | |||
| 13 | #include <boost/corosio/basic_io_context.hpp> | ||
| 14 | #include <boost/capy/ex/executor_ref.hpp> | ||
| 15 | #include <boost/capy/detail/type_id.hpp> | ||
| 16 | #include <boost/capy/coro.hpp> | ||
| 17 | |||
| 18 | namespace boost::corosio::detail { | ||
| 19 | |||
| 20 | /** Resumes a coroutine for I/O completion. | ||
| 21 | |||
| 22 | If the executor is io_context::executor_type, resumes directly | ||
| 23 | to avoid dispatch overhead. Otherwise dispatches through the | ||
| 24 | executor. No memory fence is needed since GQCS/epoll_wait | ||
| 25 | provide acquire semantics. | ||
| 26 | |||
| 27 | @param d The executor to dispatch through. | ||
| 28 | @param h The coroutine handle to resume. | ||
| 29 | */ | ||
| 30 | inline void | ||
| 31 | 120378 | resume_coro(capy::executor_ref d, capy::coro h) | |
| 32 | { | ||
| 33 | // Fast path: resume directly for io_context executor | ||
| 34 |
1/2✓ Branch 2 taken 120378 times.
✗ Branch 3 not taken.
|
120378 | if (&d.type_id() == &capy::detail::type_id<basic_io_context::executor_type>()) |
| 35 | 120378 | h.resume(); | |
| 36 | else | ||
| 37 | ✗ | d.dispatch(h); | |
| 38 | 120378 | } | |
| 39 | |||
| 40 | } // namespace boost::corosio::detail | ||
| 41 | |||
| 42 | #endif | ||
| 43 |