src/corosio/src/win_stream_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_stream_handle::~win_stream_handle()
:23
35x
0.0%
–
100.0%
boost::corosio::win_stream_handle::win_stream_handle(boost::capy::execution_context&)
:28
34x
100.0%
100.0%
100.0%
boost::corosio::win_stream_handle::assign(unsigned long long)
:38
35x
100.0%
100.0%
100.0%
boost::corosio::win_stream_handle::release()
:47
8x
100.0%
100.0%
100.0%
boost::corosio::win_stream_handle::close()
:57
35x
100.0%
100.0%
100.0%
boost::corosio::win_stream_handle::native_handle() const
:65
6x
75.0%
50.0%
83.3%
boost::corosio::win_stream_handle::cancel()
:73
1x
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_stream_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 | 35x | win_stream_handle::~win_stream_handle() | ||
| 24 | { | |||
| 25 | 35x | close(); | ||
| 26 | 35x | } | ||
| 27 | ||||
| 28 | 34x | win_stream_handle::win_stream_handle(capy::execution_context& ctx) | ||
| 29 | 34x | : io_object(handle( | ||
| 30 | ctx, | |||
| 31 | detail::use_backend_service< | |||
| 32 | detail::stream_handle_service_of, | |||
| 33 |
2/2✓ Branch 2 → 3 taken 34 times.
✓ Branch 3 → 4 taken 34 times.
|
68x | detail::stream_handle_service>(ctx))) | |
| 34 | { | |||
| 35 | 34x | } | ||
| 36 | ||||
| 37 | std::error_code | |||
| 38 | 35x | win_stream_handle::assign(native_handle_type h) noexcept | ||
| 39 | { | |||
| 40 |
2/2✓ Branch 3 → 4 taken 2 times.
✓ Branch 3 → 5 taken 33 times.
|
35x | if (is_open()) | |
| 41 | 2x | return make_error_code(error::already_open); | ||
| 42 | 33x | auto& svc = static_cast<detail::stream_handle_service&>(h_.service()); | ||
| 43 | 33x | return svc.assign_stream_handle(get(), h); | ||
| 44 | } | |||
| 45 | ||||
| 46 | capy::results<native_handle_type> | |||
| 47 | 8x | win_stream_handle::release() noexcept | ||
| 48 | { | |||
| 49 |
2/2✓ Branch 3 → 4 taken 1 time.
✓ Branch 3 → 7 taken 7 times.
|
8x | if (!is_open()) | |
| 50 | return { | |||
| 51 | 2x | make_error_code(std::errc::bad_file_descriptor), | ||
| 52 | 1x | detail::invalid_native_handle}; | ||
| 53 | 7x | return get().release_handle(); | ||
| 54 | } | |||
| 55 | ||||
| 56 | void | |||
| 57 | 35x | win_stream_handle::close() noexcept | ||
| 58 | { | |||
| 59 |
2/2✓ Branch 3 → 4 taken 16 times.
✓ Branch 3 → 5 taken 19 times.
|
35x | if (!is_open()) | |
| 60 | 16x | return; | ||
| 61 | 19x | h_.service().close(h_); | ||
| 62 | } | |||
| 63 | ||||
| 64 | native_handle_type | |||
| 65 | 6x | win_stream_handle::native_handle() const noexcept | ||
| 66 | { | |||
| 67 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 6 times.
|
6x | if (!h_) | |
| 68 | ✗ | return ~native_handle_type{}; | ||
| 69 | 6x | return get().native_handle(); | ||
| 70 | } | |||
| 71 | ||||
| 72 | void | |||
| 73 | 1x | win_stream_handle::cancel() noexcept | ||
| 74 | { | |||
| 75 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 1 time.
|
1x | if (!is_open()) | |
| 76 | ✗ | return; | ||
| 77 | 1x | get().cancel(); | ||
| 78 | } | |||
| 79 | ||||
| 80 | } // namespace boost::corosio | |||
| 81 | ||||
| 82 | #endif // BOOST_COROSIO_HAS_IOCP | |||
| 83 |