100.00% Lines (27/27)
100.00% Functions (9/9)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com) | 2 | // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com) | |||||
| 3 | // | 3 | // | |||||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 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) | 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 6 | // | 6 | // | |||||
| 7 | // Official repository: https://github.com/cppalliance/capy | 7 | // Official repository: https://github.com/cppalliance/capy | |||||
| 8 | // | 8 | // | |||||
| 9 | 9 | |||||||
| 10 | #ifndef BOOST_CAPY_DETAIL_RUN_CALLBACKS_HPP | 10 | #ifndef BOOST_CAPY_DETAIL_RUN_CALLBACKS_HPP | |||||
| 11 | #define BOOST_CAPY_DETAIL_RUN_CALLBACKS_HPP | 11 | #define BOOST_CAPY_DETAIL_RUN_CALLBACKS_HPP | |||||
| 12 | 12 | |||||||
| 13 | - | #include <boost/capy/detail/stop_requested_exception.hpp> | ||||||
| 14 | #include <boost/capy/detail/config.hpp> | 13 | #include <boost/capy/detail/config.hpp> | |||||
| 15 | 14 | |||||||
| 16 | #include <concepts> | 15 | #include <concepts> | |||||
| 17 | #include <exception> | 16 | #include <exception> | |||||
| 18 | #include <type_traits> | 17 | #include <type_traits> | |||||
| 19 | #include <utility> | 18 | #include <utility> | |||||
| 20 | 19 | |||||||
| 21 | namespace boost { | 20 | namespace boost { | |||||
| 22 | namespace capy { | 21 | namespace capy { | |||||
| 23 | namespace detail { | 22 | namespace detail { | |||||
| 24 | 23 | |||||||
| 25 | struct default_handler | 24 | struct default_handler | |||||
| 26 | { | 25 | { | |||||
| 27 | template<class T> | 26 | template<class T> | |||||
| HITCBC | 28 | 3 | void operator()(T&&) const noexcept | 27 | 3 | void operator()(T&&) const noexcept | ||
| 29 | { | 28 | { | |||||
| HITCBC | 30 | 3 | } | 29 | 3 | } | ||
| 31 | 30 | |||||||
| HITCBC | 32 | 1849 | void operator()() const noexcept | 31 | 1859 | void operator()() const noexcept | ||
| 33 | { | 32 | { | |||||
| HITCBC | 34 | 1849 | } | 33 | 1859 | } | ||
| 35 | 34 | |||||||
| HITCBC | 36 | 1034 | void operator()(std::exception_ptr ep) const | 35 | 1033 | void operator()(std::exception_ptr ep) const | ||
| 37 | { | 36 | { | |||||
| HITCBC | 38 | - | 1034 | if(!ep) | 37 | + | 1033 | if(ep) |
| DCB | 39 | - | 1 | return; | ||||
| 40 | - | try | ||||||
| 41 | - | { | ||||||
| DCB | 42 | - | 2066 | } | ||||
| 43 | - | catch(stop_requested_exception const&) | ||||||
| DCB | 44 | - | 1033 | { | ||||
| 45 | - | // Cancellation is a normal completion, not an error. | ||||||
| 46 | - | } | ||||||
| DCB | 47 | - | 5 | // A real unhandled exception propagates to the trampoline's | ||||
| 48 | - | // unhandled_exception, which terminates. | ||||||
| HITGIC | 49 | std::rethrow_exception(ep); | 38 | 1032 | std::rethrow_exception(ep); | |||
| HITGIC | 50 | } | 39 | 1 | } | |||
| 51 | }; | 40 | }; | |||||
| 52 | 41 | |||||||
| 53 | template<class H1, class H2> | 42 | template<class H1, class H2> | |||||
| 54 | struct handler_pair | 43 | struct handler_pair | |||||
| 55 | { | 44 | { | |||||
| 56 | static_assert( | 45 | static_assert( | |||||
| 57 | std::is_nothrow_move_constructible_v<H1> && | 46 | std::is_nothrow_move_constructible_v<H1> && | |||||
| 58 | std::is_nothrow_move_constructible_v<H2>, | 47 | std::is_nothrow_move_constructible_v<H2>, | |||||
| 59 | "Handlers must be nothrow move constructible"); | 48 | "Handlers must be nothrow move constructible"); | |||||
| 60 | 49 | |||||||
| 61 | H1 h1_; | 50 | H1 h1_; | |||||
| 62 | H2 h2_; | 51 | H2 h2_; | |||||
| 63 | 52 | |||||||
| 64 | template<class T> | 53 | template<class T> | |||||
| HITCBC | 65 | 80 | void operator()(T&& v) | 54 | 80 | void operator()(T&& v) | ||
| 66 | { | 55 | { | |||||
| HITCBC | 67 | 80 | h1_(std::forward<T>(v)); | 56 | 80 | h1_(std::forward<T>(v)); | ||
| HITCBC | 68 | 80 | } | 57 | 80 | } | ||
| 69 | 58 | |||||||
| HITCBC | 70 | 21 | void operator()() | 59 | 21 | void operator()() | ||
| 71 | { | 60 | { | |||||
| HITCBC | 72 | 21 | h1_(); | 61 | 21 | h1_(); | ||
| HITCBC | 73 | 21 | } | 62 | 21 | } | ||
| 74 | 63 | |||||||
| HITCBC | 75 | 31 | void operator()(std::exception_ptr ep) | 64 | 31 | void operator()(std::exception_ptr ep) | ||
| 76 | { | 65 | { | |||||
| HITCBC | 77 | 31 | h2_(ep); | 66 | 31 | h2_(ep); | ||
| HITCBC | 78 | 31 | } | 67 | 31 | } | ||
| 79 | }; | 68 | }; | |||||
| 80 | 69 | |||||||
| 81 | template<class H1> | 70 | template<class H1> | |||||
| 82 | struct handler_pair<H1, default_handler> | 71 | struct handler_pair<H1, default_handler> | |||||
| 83 | { | 72 | { | |||||
| 84 | static_assert( | 73 | static_assert( | |||||
| 85 | std::is_nothrow_move_constructible_v<H1>, | 74 | std::is_nothrow_move_constructible_v<H1>, | |||||
| 86 | "Handler must be nothrow move constructible"); | 75 | "Handler must be nothrow move constructible"); | |||||
| 87 | 76 | |||||||
| 88 | H1 h1_; | 77 | H1 h1_; | |||||
| 89 | 78 | |||||||
| 90 | template<class T> | 79 | template<class T> | |||||
| HITCBC | 91 | 137 | void operator()(T&& v) | 80 | 137 | void operator()(T&& v) | ||
| 92 | { | 81 | { | |||||
| HITCBC | 93 | 137 | h1_(std::forward<T>(v)); | 82 | 137 | h1_(std::forward<T>(v)); | ||
| HITCBC | 94 | 137 | } | 83 | 137 | } | ||
| 95 | 84 | |||||||
| HITCBC | 96 | 3565 | void operator()() | 85 | 3575 | void operator()() | ||
| 97 | { | 86 | { | |||||
| HITCBC | 98 | 3565 | h1_(); | 87 | 3575 | h1_(); | ||
| HITCBC | 99 | 3565 | } | 88 | 3575 | } | ||
| 100 | 89 | |||||||
| HITCBC | 101 | 2059 | void operator()(std::exception_ptr ep) | 90 | 2059 | void operator()(std::exception_ptr ep) | ||
| 102 | { | 91 | { | |||||
| 103 | if constexpr(std::invocable<H1, std::exception_ptr>) | 92 | if constexpr(std::invocable<H1, std::exception_ptr>) | |||||
| HITCBC | 104 | 2058 | h1_(ep); | 93 | 2058 | h1_(ep); | ||
| 105 | else | 94 | else | |||||
| HITCBC | 106 | - | 2 | default_handler{}(ep); | 95 | + | 1 | std::rethrow_exception(ep); |
| HITCBC | 107 | 1032 | } | 96 | 1032 | } | ||
| 108 | }; | 97 | }; | |||||
| 109 | 98 | |||||||
| 110 | } // namespace detail | 99 | } // namespace detail | |||||
| 111 | } // namespace capy | 100 | } // namespace capy | |||||
| 112 | } // namespace boost | 101 | } // namespace boost | |||||
| 113 | 102 | |||||||
| 114 | #endif | 103 | #endif | |||||