libs/capy/include/boost/capy/detail/await_suspend_helper.hpp
0.0% Lines (0/3)
0.0% Functions (0/5)
-% Branches (0/0)
libs/capy/include/boost/capy/detail/await_suspend_helper.hpp
| Line | Hits | Source Code |
|---|---|---|
| 1 | // | |
| 2 | // Copyright (c) 2025 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/capy | |
| 8 | // | |
| 9 | ||
| 10 | #ifndef BOOST_CAPY_DETAIL_AWAIT_SUSPEND_HELPER_HPP | |
| 11 | #define BOOST_CAPY_DETAIL_AWAIT_SUSPEND_HELPER_HPP | |
| 12 | ||
| 13 | #include <boost/capy/coro.hpp> | |
| 14 | #include <boost/capy/ex/executor_ref.hpp> | |
| 15 | ||
| 16 | #include <stop_token> | |
| 17 | #include <type_traits> | |
| 18 | ||
| 19 | namespace boost { | |
| 20 | namespace capy { | |
| 21 | namespace detail { | |
| 22 | ||
| 23 | // Helper to normalize await_suspend return types to coro | |
| 24 | template<typename Awaitable> | |
| 25 | ✗ | coro call_await_suspend( |
| 26 | Awaitable* a, | |
| 27 | coro h, | |
| 28 | executor_ref ex, | |
| 29 | std::stop_token token) | |
| 30 | { | |
| 31 | using R = decltype(a->await_suspend(h, ex, token)); | |
| 32 | if constexpr (std::is_void_v<R>) | |
| 33 | { | |
| 34 | ✗ | a->await_suspend(h, ex, token); |
| 35 | ✗ | return std::noop_coroutine(); |
| 36 | } | |
| 37 | else if constexpr (std::is_same_v<R, bool>) | |
| 38 | { | |
| 39 | if(a->await_suspend(h, ex, token)) | |
| 40 | return std::noop_coroutine(); | |
| 41 | return h; | |
| 42 | } | |
| 43 | else | |
| 44 | { | |
| 45 | return a->await_suspend(h, ex, token); | |
| 46 | } | |
| 47 | } | |
| 48 | ||
| 49 | } // namespace detail | |
| 50 | } // namespace capy | |
| 51 | } // namespace boost | |
| 52 | ||
| 53 | #endif | |
| 54 |