include/boost/capy/asio/detail/asio_coroutine_unique_handle.hpp
75.0% Lines (9/12)
80.0% List of functions (4/5)
Functions (5)
Function
Calls
Lines
Blocks
boost::capy::detail::asio_coroutine_unique_handle::deleter::operator()(void*) const
:25
0
0.0%
0.0%
boost::capy::detail::asio_coroutine_unique_handle::asio_coroutine_unique_handle(std::__n4861::coroutine_handle<void>)
:32
11x
100.0%
100.0%
boost::capy::detail::asio_coroutine_unique_handle::asio_coroutine_unique_handle(boost::capy::detail::asio_coroutine_unique_handle&&)
:35
40x
100.0%
100.0%
boost::capy::detail::asio_coroutine_unique_handle::operator()()
:39
8x
100.0%
100.0%
boost::capy::detail::asio_coroutine_unique_handle::release()
:44
11x
100.0%
100.0%
| Line | TLA | Hits | Source 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; | ||
| 25 | ✗ | void operator()(void * h) const | |
| 26 | { | ||
| 27 | ✗ | std::coroutine_handle<void>::from_address(h).destroy(); | |
| 28 | ✗ | } | |
| 29 | }; | ||
| 30 | std::unique_ptr<void, deleter> handle; | ||
| 31 | |||
| 32 | 11x | asio_coroutine_unique_handle( | |
| 33 | 11x | std::coroutine_handle<void> h) : handle(h.address()) {} | |
| 34 | |||
| 35 | 40x | asio_coroutine_unique_handle( | |
| 36 | asio_coroutine_unique_handle && | ||
| 37 | ) noexcept = default; | ||
| 38 | |||
| 39 | 8x | void operator()() | |
| 40 | { | ||
| 41 | 8x | release().resume(); | |
| 42 | 8x | } | |
| 43 | |||
| 44 | 11x | std::coroutine_handle<> release() | |
| 45 | { | ||
| 46 | 11x | return std::coroutine_handle<void>::from_address( | |
| 47 | handle.release() | ||
| 48 | 11x | ); | |
| 49 | } | ||
| 50 | }; | ||
| 51 | |||
| 52 | } | ||
| 53 | |||
| 54 | #endif | ||
| 55 | |||
| 56 |