src/corosio/src/win_object_handle.cpp
93.1% Lines (27 / 29)
83.3% Branches (10 / 12)
100.0% Functions (7 / 7)
Functions (7)
Function
Calls
Lines
Branches
Blocks
boost::corosio::win_object_handle::~win_object_handle()
:23
2827x
0.0%
–
100.0%
boost::corosio::win_object_handle::win_object_handle(boost::capy::execution_context&)
:28
2825x
100.0%
100.0%
100.0%
boost::corosio::win_object_handle::assign(unsigned long long)
:38
2827x
100.0%
100.0%
100.0%
boost::corosio::win_object_handle::release()
:47
202x
100.0%
100.0%
100.0%
boost::corosio::win_object_handle::close()
:57
3029x
100.0%
100.0%
100.0%
boost::corosio::win_object_handle::native_handle() const
:65
3x
75.0%
50.0%
83.3%
boost::corosio::win_object_handle::cancel()
:73
2201x
75.0%
50.0%
83.3%
| Line | Branch | TLA | Hits | Source Code |
|---|---|---|---|---|
| 1 | // | |||
| 2 | // Copyright (c) 2026 Michael Vandeberg | |||
| 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/corosio | |||
| 8 | // | |||
| 9 | ||||
| 10 | #include <boost/corosio/win_object_handle.hpp> | |||
| 11 | ||||
| 12 | #include <boost/corosio/detail/platform.hpp> | |||
| 13 | ||||
| 14 | #if BOOST_COROSIO_HAS_IOCP | |||
| 15 | ||||
| 16 | #include <boost/corosio/detail/win_handle_service.hpp> | |||
| 17 | #include <boost/corosio/error.hpp> | |||
| 18 | ||||
| 19 | #include "src/detail/use_backend_service.hpp" | |||
| 20 | ||||
| 21 | namespace boost::corosio { | |||
| 22 | ||||
| 23 | 2827x | win_object_handle::~win_object_handle() | ||
| 24 | { | |||
| 25 | 2827x | close(); | ||
| 26 | 2827x | } | ||
| 27 | ||||
| 28 | 2825x | win_object_handle::win_object_handle(capy::execution_context& ctx) | ||
| 29 | 2825x | : io_object(handle( | ||
| 30 | ctx, | |||
| 31 | detail::use_backend_service< | |||
| 32 | detail::object_handle_service_of, | |||
| 33 |
2/2✓ Branch 2 → 3 taken 2825 times.
✓ Branch 3 → 4 taken 2825 times.
|
2825x | detail::object_handle_service>(ctx))) | |
| 34 | { | |||
| 35 | 2825x | } | ||
| 36 | ||||
| 37 | std::error_code | |||
| 38 | 2827x | win_object_handle::assign(native_handle_type h) noexcept | ||
| 39 | { | |||
| 40 |
2/2✓ Branch 3 → 4 taken 2 times.
✓ Branch 3 → 5 taken 2825 times.
|
2827x | if (is_open()) | |
| 41 | 2x | return make_error_code(error::already_open); | ||
| 42 | 2825x | auto& svc = static_cast<detail::object_handle_service&>(h_.service()); | ||
| 43 | 2825x | return svc.assign_object_handle(get(), h); | ||
| 44 | } | |||
| 45 | ||||
| 46 | capy::results<native_handle_type> | |||
| 47 | 202x | win_object_handle::release() noexcept | ||
| 48 | { | |||
| 49 |
2/2✓ Branch 3 → 4 taken 1 time.
✓ Branch 3 → 7 taken 201 times.
|
202x | if (!is_open()) | |
| 50 | return { | |||
| 51 | 2x | make_error_code(std::errc::bad_file_descriptor), | ||
| 52 | 1x | detail::invalid_native_handle}; | ||
| 53 | 201x | return {std::error_code{}, get().release_handle()}; | ||
| 54 | } | |||
| 55 | ||||
| 56 | void | |||
| 57 | 3029x | win_object_handle::close() noexcept | ||
| 58 | { | |||
| 59 |
2/2✓ Branch 3 → 4 taken 411 times.
✓ Branch 3 → 5 taken 2618 times.
|
3029x | if (!is_open()) | |
| 60 | 411x | return; | ||
| 61 | 2618x | h_.service().close(h_); | ||
| 62 | } | |||
| 63 | ||||
| 64 | native_handle_type | |||
| 65 | 3x | win_object_handle::native_handle() const noexcept | ||
| 66 | { | |||
| 67 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 3 times.
|
3x | if (!h_) | |
| 68 | ✗ | return ~native_handle_type{}; | ||
| 69 | 3x | return get().native_handle(); | ||
| 70 | } | |||
| 71 | ||||
| 72 | void | |||
| 73 | 2201x | win_object_handle::cancel() noexcept | ||
| 74 | { | |||
| 75 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2201 times.
|
2201x | if (!is_open()) | |
| 76 | ✗ | return; | ||
| 77 | 2201x | get().cancel(); | ||
| 78 | } | |||
| 79 | ||||
| 80 | } // namespace boost::corosio | |||
| 81 | ||||
| 82 | #endif // BOOST_COROSIO_HAS_IOCP | |||
| 83 |