include/boost/corosio/detail/win_handle_service.hpp
100.0% Lines (6 / 6)
-% Branches (0 / 0)
100.0% Functions (6 / 6)
Functions (6)
Function
Calls
Lines
Branches
Blocks
boost::corosio::detail::stream_handle_service::stream_handle_service()
:54
34x
100.0%
–
100.0%
boost::corosio::detail::stream_handle_service::~stream_handle_service()
:55
34x
100.0%
–
100.0%
boost::corosio::detail::random_access_handle_service::random_access_handle_service()
:81
25x
100.0%
–
100.0%
boost::corosio::detail::random_access_handle_service::~random_access_handle_service()
:82
25x
100.0%
–
100.0%
boost::corosio::detail::object_handle_service::object_handle_service()
:107
2826x
100.0%
–
100.0%
boost::corosio::detail::object_handle_service::~object_handle_service()
:108
2826x
100.0%
–
100.0%
| 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 | #ifndef BOOST_COROSIO_DETAIL_WIN_HANDLE_SERVICE_HPP | |||
| 11 | #define BOOST_COROSIO_DETAIL_WIN_HANDLE_SERVICE_HPP | |||
| 12 | ||||
| 13 | #include <boost/corosio/detail/config.hpp> | |||
| 14 | #include <boost/corosio/detail/platform.hpp> | |||
| 15 | ||||
| 16 | #if BOOST_COROSIO_HAS_IOCP | |||
| 17 | ||||
| 18 | #include <boost/corosio/win_object_handle.hpp> | |||
| 19 | #include <boost/corosio/win_random_access_handle.hpp> | |||
| 20 | #include <boost/corosio/win_stream_handle.hpp> | |||
| 21 | #include <boost/capy/ex/execution_context.hpp> | |||
| 22 | ||||
| 23 | #include <system_error> | |||
| 24 | ||||
| 25 | namespace boost::corosio::detail { | |||
| 26 | ||||
| 27 | /* Abstract handle service bases. The IOCP backend installs the | |||
| 28 | concrete services on first use; the public .cpp files retrieve them | |||
| 29 | through use_backend_service under these keys. | |||
| 30 | */ | |||
| 31 | ||||
| 32 | /// Abstract service behind @ref win_stream_handle. | |||
| 33 | class BOOST_COROSIO_DECL stream_handle_service | |||
| 34 | : public capy::execution_context::service | |||
| 35 | , public io_object::io_service | |||
| 36 | { | |||
| 37 | public: | |||
| 38 | /// Identifies this service for execution_context lookup. | |||
| 39 | using key_type = stream_handle_service; | |||
| 40 | ||||
| 41 | /** Adopt an existing handle. | |||
| 42 | ||||
| 43 | The implementation is closed. On failure it stays closed and | |||
| 44 | the caller retains ownership of @a h. | |||
| 45 | ||||
| 46 | @param impl The implementation to assign to. | |||
| 47 | @param h The native handle to adopt. | |||
| 48 | @return Error code on failure, empty on success. | |||
| 49 | */ | |||
| 50 | virtual std::error_code assign_stream_handle( | |||
| 51 | win_stream_handle::implementation& impl, native_handle_type h) = 0; | |||
| 52 | ||||
| 53 | protected: | |||
| 54 | 34x | stream_handle_service() = default; | ||
| 55 | 34x | ~stream_handle_service() override = default; | ||
| 56 | }; | |||
| 57 | ||||
| 58 | /// Abstract service behind @ref win_random_access_handle. | |||
| 59 | class BOOST_COROSIO_DECL random_access_handle_service | |||
| 60 | : public capy::execution_context::service | |||
| 61 | , public io_object::io_service | |||
| 62 | { | |||
| 63 | public: | |||
| 64 | /// Identifies this service for execution_context lookup. | |||
| 65 | using key_type = random_access_handle_service; | |||
| 66 | ||||
| 67 | /** Adopt an existing handle. | |||
| 68 | ||||
| 69 | The implementation is closed. On failure it stays closed and | |||
| 70 | the caller retains ownership of @a h. | |||
| 71 | ||||
| 72 | @param impl The implementation to assign to. | |||
| 73 | @param h The native handle to adopt. | |||
| 74 | @return Error code on failure, empty on success. | |||
| 75 | */ | |||
| 76 | virtual std::error_code assign_random_access_handle( | |||
| 77 | win_random_access_handle::implementation& impl, | |||
| 78 | native_handle_type h) = 0; | |||
| 79 | ||||
| 80 | protected: | |||
| 81 | 25x | random_access_handle_service() = default; | ||
| 82 | 25x | ~random_access_handle_service() override = default; | ||
| 83 | }; | |||
| 84 | ||||
| 85 | /// Abstract service behind @ref win_object_handle. | |||
| 86 | class BOOST_COROSIO_DECL object_handle_service | |||
| 87 | : public capy::execution_context::service | |||
| 88 | , public io_object::io_service | |||
| 89 | { | |||
| 90 | public: | |||
| 91 | /// Identifies this service for execution_context lookup. | |||
| 92 | using key_type = object_handle_service; | |||
| 93 | ||||
| 94 | /** Adopt an existing waitable handle. | |||
| 95 | ||||
| 96 | The implementation is closed. On failure it stays closed and | |||
| 97 | the caller retains ownership of @a h. | |||
| 98 | ||||
| 99 | @param impl The implementation to assign to. | |||
| 100 | @param h The native handle to adopt. | |||
| 101 | @return Error code on failure, empty on success. | |||
| 102 | */ | |||
| 103 | virtual std::error_code assign_object_handle( | |||
| 104 | win_object_handle::implementation& impl, native_handle_type h) = 0; | |||
| 105 | ||||
| 106 | protected: | |||
| 107 | 2826x | object_handle_service() = default; | ||
| 108 | 2826x | ~object_handle_service() override = default; | ||
| 109 | }; | |||
| 110 | ||||
| 111 | } // namespace boost::corosio::detail | |||
| 112 | ||||
| 113 | #endif // BOOST_COROSIO_HAS_IOCP | |||
| 114 | ||||
| 115 | #endif | |||
| 116 |