100.00% Lines (2/2)
100.00% Functions (2/2)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2026 Michael Vandeberg | 2 | // Copyright (c) 2026 Michael Vandeberg | |||||
| 3 | // | 3 | // | |||||
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 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) | 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 6 | // | 6 | // | |||||
| 7 | // Official repository: https://github.com/cppalliance/corosio | 7 | // Official repository: https://github.com/cppalliance/corosio | |||||
| 8 | // | 8 | // | |||||
| 9 | 9 | |||||||
| 10 | #ifndef BOOST_COROSIO_DETAIL_DESCRIPTOR_SERVICE_HPP | 10 | #ifndef BOOST_COROSIO_DETAIL_DESCRIPTOR_SERVICE_HPP | |||||
| 11 | #define BOOST_COROSIO_DETAIL_DESCRIPTOR_SERVICE_HPP | 11 | #define BOOST_COROSIO_DETAIL_DESCRIPTOR_SERVICE_HPP | |||||
| 12 | 12 | |||||||
| 13 | #include <boost/corosio/detail/config.hpp> | 13 | #include <boost/corosio/detail/config.hpp> | |||||
| 14 | #include <boost/corosio/detail/platform.hpp> | 14 | #include <boost/corosio/detail/platform.hpp> | |||||
| 15 | 15 | |||||||
| 16 | #if BOOST_COROSIO_POSIX | 16 | #if BOOST_COROSIO_POSIX | |||||
| 17 | 17 | |||||||
| 18 | #include <boost/corosio/posix_stream_descriptor.hpp> | 18 | #include <boost/corosio/posix_stream_descriptor.hpp> | |||||
| 19 | #include <boost/capy/ex/execution_context.hpp> | 19 | #include <boost/capy/ex/execution_context.hpp> | |||||
| 20 | 20 | |||||||
| 21 | #include <system_error> | 21 | #include <system_error> | |||||
| 22 | 22 | |||||||
| 23 | namespace boost::corosio::detail { | 23 | namespace boost::corosio::detail { | |||||
| 24 | 24 | |||||||
| 25 | /* Abstract descriptor service base class. | 25 | /* Abstract descriptor service base class. | |||||
| 26 | 26 | |||||||
| 27 | Concrete implementations (epoll, select, kqueue, uring) inherit | 27 | Concrete implementations (epoll, select, kqueue, uring) inherit | |||||
| 28 | from this class. The three reactor backends register the adopted | 28 | from this class. The three reactor backends register the adopted | |||||
| 29 | fd with their reactor; uring has no adopt-time registration and | 29 | fd with their reactor; uring has no adopt-time registration and | |||||
| 30 | only takes ownership of it. | 30 | only takes ownership of it. | |||||
| 31 | posix_stream_descriptor.cpp creates the running backend's service | 31 | posix_stream_descriptor.cpp creates the running backend's service | |||||
| 32 | on first use via use_backend_service. | 32 | on first use via use_backend_service. | |||||
| 33 | */ | 33 | */ | |||||
| 34 | class BOOST_COROSIO_DECL descriptor_service | 34 | class BOOST_COROSIO_DECL descriptor_service | |||||
| 35 | : public capy::execution_context::service | 35 | : public capy::execution_context::service | |||||
| 36 | , public io_object::io_service | 36 | , public io_object::io_service | |||||
| 37 | { | 37 | { | |||||
| 38 | public: | 38 | public: | |||||
| 39 | /// Identifies this service for execution_context lookup. | 39 | /// Identifies this service for execution_context lookup. | |||||
| 40 | using key_type = descriptor_service; | 40 | using key_type = descriptor_service; | |||||
| 41 | 41 | |||||||
| 42 | /** Adopt an existing native descriptor. | 42 | /** Adopt an existing native descriptor. | |||||
| 43 | 43 | |||||||
| 44 | The implementation is closed. On failure it stays closed and | 44 | The implementation is closed. On failure it stays closed and | |||||
| 45 | the caller retains ownership of @a fd. On success the | 45 | the caller retains ownership of @a fd. On success the | |||||
| 46 | implementation takes ownership and will close it. | 46 | implementation takes ownership and will close it. | |||||
| 47 | 47 | |||||||
| 48 | @param impl The descriptor implementation to assign to. | 48 | @param impl The descriptor implementation to assign to. | |||||
| 49 | @param fd The native descriptor to adopt. | 49 | @param fd The native descriptor to adopt. | |||||
| 50 | @return Error code on failure, empty on success. | 50 | @return Error code on failure, empty on success. | |||||
| 51 | */ | 51 | */ | |||||
| 52 | virtual std::error_code assign_descriptor( | 52 | virtual std::error_code assign_descriptor( | |||||
| 53 | posix_stream_descriptor::implementation& impl, | 53 | posix_stream_descriptor::implementation& impl, | |||||
| 54 | native_handle_type fd) = 0; | 54 | native_handle_type fd) = 0; | |||||
| 55 | 55 | |||||||
| 56 | protected: | 56 | protected: | |||||
| HITCBC | 57 | 105 | descriptor_service() = default; | 57 | 105 | descriptor_service() = default; | ||
| HITCBC | 58 | 105 | ~descriptor_service() override = default; | 58 | 105 | ~descriptor_service() override = default; | ||
| 59 | }; | 59 | }; | |||||
| 60 | 60 | |||||||
| 61 | } // namespace boost::corosio::detail | 61 | } // namespace boost::corosio::detail | |||||
| 62 | 62 | |||||||
| 63 | #endif // BOOST_COROSIO_POSIX | 63 | #endif // BOOST_COROSIO_POSIX | |||||
| 64 | 64 | |||||||
| 65 | #endif | 65 | #endif | |||||