src/corosio/src/win_object_handle.cpp
86.2% Lines (25/29)
100.0% List of functions (7/7)
75.0% Branches (9/12)
Functions (7)
Function
Calls
Lines
Branches
Blocks
boost::corosio::win_object_handle::~win_object_handle()
:24
2824x
0.0%
–
100.0%
boost::corosio::win_object_handle::win_object_handle(boost::capy::execution_context&)
:29
2823x
100.0%
100.0%
100.0%
boost::corosio::win_object_handle::assign(unsigned long long)
:39
2826x
100.0%
100.0%
100.0%
boost::corosio::win_object_handle::release()
:48
201x
60.0%
50.0%
75.0%
boost::corosio::win_object_handle::close()
:58
3026x
100.0%
100.0%
100.0%
boost::corosio::win_object_handle::native_handle() const
:66
3x
75.0%
50.0%
83.3%
boost::corosio::win_object_handle::cancel()
:74
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/except.hpp> | |||
| 17 | #include <boost/corosio/detail/win_handle_service.hpp> | |||
| 18 | #include <boost/corosio/error.hpp> | |||
| 19 | ||||
| 20 | #include "src/detail/use_backend_service.hpp" | |||
| 21 | ||||
| 22 | namespace boost::corosio { | |||
| 23 | ||||
| 24 | 2824x | win_object_handle::~win_object_handle() | ||
| 25 | { | |||
| 26 | 2824x | close(); | ||
| 27 | 2824x | } | ||
| 28 | ||||
| 29 | 2823x | win_object_handle::win_object_handle(capy::execution_context& ctx) | ||
| 30 | 2823x | : io_object(handle( | ||
| 31 | ctx, | |||
| 32 | detail::use_backend_service< | |||
| 33 | detail::object_handle_service_of, | |||
| 34 |
2/2✓ Branch 2 → 3 taken 2823 times.
✓ Branch 3 → 4 taken 2823 times.
|
2823x | detail::object_handle_service>(ctx))) | |
| 35 | { | |||
| 36 | 2823x | } | ||
| 37 | ||||
| 38 | std::error_code | |||
| 39 | 2826x | win_object_handle::assign(native_handle_type h) noexcept | ||
| 40 | { | |||
| 41 |
2/2✓ Branch 3 → 4 taken 2 times.
✓ Branch 3 → 5 taken 2824 times.
|
2826x | if (is_open()) | |
| 42 | 2x | return make_error_code(error::already_open); | ||
| 43 | 2824x | auto& svc = static_cast<detail::object_handle_service&>(h_.service()); | ||
| 44 | 2824x | return svc.assign_object_handle(get(), h); | ||
| 45 | } | |||
| 46 | ||||
| 47 | native_handle_type | |||
| 48 | 201x | win_object_handle::release() | ||
| 49 | { | |||
| 50 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 6 taken 201 times.
|
201x | if (!is_open()) | |
| 51 | ✗ | detail::throw_system_error( | ||
| 52 | ✗ | make_error_code(std::errc::bad_file_descriptor), | ||
| 53 | "win_object_handle::release"); | |||
| 54 | 201x | return get().release_handle(); | ||
| 55 | } | |||
| 56 | ||||
| 57 | void | |||
| 58 | 3026x | win_object_handle::close() noexcept | ||
| 59 | { | |||
| 60 |
2/2✓ Branch 3 → 4 taken 409 times.
✓ Branch 3 → 5 taken 2617 times.
|
3026x | if (!is_open()) | |
| 61 | 409x | return; | ||
| 62 | 2617x | h_.service().close(h_); | ||
| 63 | } | |||
| 64 | ||||
| 65 | native_handle_type | |||
| 66 | 3x | win_object_handle::native_handle() const noexcept | ||
| 67 | { | |||
| 68 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 3 times.
|
3x | if (!h_) | |
| 69 | ✗ | return ~native_handle_type{}; | ||
| 70 | 3x | return get().native_handle(); | ||
| 71 | } | |||
| 72 | ||||
| 73 | void | |||
| 74 | 2201x | win_object_handle::cancel() noexcept | ||
| 75 | { | |||
| 76 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2201 times.
|
2201x | if (!is_open()) | |
| 77 | ✗ | return; | ||
| 78 | 2201x | get().cancel(); | ||
| 79 | } | |||
| 80 | ||||
| 81 | } // namespace boost::corosio | |||
| 82 | ||||
| 83 | #endif // BOOST_COROSIO_HAS_IOCP | |||
| 84 |