LCOV - code coverage report
Current view: top level - corosio/detail - dispatch_coro.hpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 100.0 % 4 4
Test Date: 2026-03-26 16:40:44 Functions: 100.0 % 1 1

           TLA  Line data    Source code
       1                 : //
       2                 : // Copyright (c) 2026 Vinnie Falco (vinnie.falco@gmail.com)
       3                 : // Copyright (c) 2026 Steve Gerbino
       4                 : //
       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)
       7                 : //
       8                 : // Official repository: https://github.com/cppalliance/corosio
       9                 : //
      10                 : 
      11                 : #ifndef BOOST_COROSIO_DETAIL_DISPATCH_CORO_HPP
      12                 : #define BOOST_COROSIO_DETAIL_DISPATCH_CORO_HPP
      13                 : 
      14                 : #include <boost/corosio/io_context.hpp>
      15                 : #include <boost/capy/continuation.hpp>
      16                 : #include <boost/capy/ex/executor_ref.hpp>
      17                 : #include <boost/capy/detail/type_id.hpp>
      18                 : #include <coroutine>
      19                 : 
      20                 : namespace boost::corosio::detail {
      21                 : 
      22                 : /** Returns a handle for symmetric transfer on I/O completion.
      23                 : 
      24                 :     If the executor is io_context::executor_type, returns `c.h`
      25                 :     directly (fast path). Otherwise dispatches through the
      26                 :     executor, which returns `c.h` or `noop_coroutine()`.
      27                 : 
      28                 :     Callers in coroutine machinery should return the result
      29                 :     for symmetric transfer. Callers at the scheduler pump
      30                 :     level should call `.resume()` on the result.
      31                 : 
      32                 :     @param ex The executor to dispatch through.
      33                 :     @param c The continuation to dispatch. Must remain at a
      34                 :              stable address until dequeued by the executor.
      35                 : 
      36                 :     @return A handle for symmetric transfer or `std::noop_coroutine()`.
      37                 : */
      38                 : inline std::coroutine_handle<>
      39 HIT      429699 : dispatch_coro(capy::executor_ref ex, capy::continuation& c)
      40                 : {
      41          429699 :     if (ex.target<io_context::executor_type>() != nullptr)
      42          429690 :         return c.h;
      43               9 :     return ex.dispatch(c);
      44                 : }
      45                 : 
      46                 : } // namespace boost::corosio::detail
      47                 : 
      48                 : #endif
        

Generated by: LCOV version 2.3