75.00% Lines (9/12)
80.00% Functions (4/5)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | + | // | ||||||
| 2 | + | // Copyright (c) 2026 Vinnie Falco (vinnie.falco@gmail.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 | + | |||||||
| 11 | + | #ifndef BOOST_CAPY_ASIO_DETAIL_ASIO_COROUTINE_UNIQUE_HANDLE | ||||||
| 12 | + | #define BOOST_CAPY_ASIO_DETAIL_ASIO_COROUTINE_UNIQUE_HANDLE | ||||||
| 13 | + | |||||||
| 14 | + | #include <coroutine> | ||||||
| 15 | + | #include <memory> | ||||||
| 16 | + | |||||||
| 17 | + | namespace boost::capy::detail | ||||||
| 18 | + | { | ||||||
| 19 | + | |||||||
| 20 | + | struct asio_coroutine_unique_handle | ||||||
| 21 | + | { | ||||||
| 22 | + | struct deleter | ||||||
| 23 | + | { | ||||||
| 24 | + | deleter() = default; | ||||||
| MISUNC | 25 | + | ✗ | void operator()(void * h) const | ||||
| 26 | + | { | ||||||
| MISUNC | 27 | + | ✗ | std::coroutine_handle<void>::from_address(h).destroy(); | ||||
| MISUNC | 28 | + | ✗ | } | ||||
| 29 | + | }; | ||||||
| 30 | + | std::unique_ptr<void, deleter> handle; | ||||||
| 31 | + | |||||||
| HITGNC | 32 | + | 11 | asio_coroutine_unique_handle( | ||||
| HITGNC | 33 | + | 11 | std::coroutine_handle<void> h) : handle(h.address()) {} | ||||
| 34 | + | |||||||
| HITGNC | 35 | + | 40 | asio_coroutine_unique_handle( | ||||
| 36 | + | asio_coroutine_unique_handle && | ||||||
| 37 | + | ) noexcept = default; | ||||||
| 38 | + | |||||||
| HITGNC | 39 | + | 8 | void operator()() | ||||
| 40 | + | { | ||||||
| HITGNC | 41 | + | 8 | release().resume(); | ||||
| HITGNC | 42 | + | 8 | } | ||||
| 43 | + | |||||||
| HITGNC | 44 | + | 11 | std::coroutine_handle<> release() | ||||
| 45 | + | { | ||||||
| HITGNC | 46 | + | 11 | return std::coroutine_handle<void>::from_address( | ||||
| 47 | + | handle.release() | ||||||
| HITGNC | 48 | + | 11 | ); | ||||
| 49 | + | } | ||||||
| 50 | + | }; | ||||||
| 51 | + | |||||||
| 52 | + | } | ||||||
| 53 | + | |||||||
| 54 | + | #endif | ||||||
| 55 | + | |||||||