include/boost/corosio/native/detail/reactor/reactor_op_base.hpp
50.0% Lines (4/8)
33.3% List of functions (1/3)
Functions (3)
| Line | TLA | Hits | Source Code |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2026 Steve Gerbino | ||
| 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_NATIVE_DETAIL_REACTOR_REACTOR_OP_BASE_HPP | ||
| 11 | #define BOOST_COROSIO_NATIVE_DETAIL_REACTOR_REACTOR_OP_BASE_HPP | ||
| 12 | |||
| 13 | #include <boost/corosio/native/detail/coro_op.hpp> | ||
| 14 | |||
| 15 | #include <cstddef> | ||
| 16 | |||
| 17 | namespace boost::corosio::detail { | ||
| 18 | |||
| 19 | /** Non-template base for reactor operations. | ||
| 20 | |||
| 21 | Adds the reactor-specific result model (the recorded errno + bytes and | ||
| 22 | the perform_io() readiness re-run) on top of coro_op, the shared op | ||
| 23 | envelope (coroutine handle, executor, output pointers, stop_token wiring, | ||
| 24 | cancelled flag, impl_ptr keepalive) common to every backend. | ||
| 25 | |||
| 26 | Kept as a non-template layer so reactor_descriptor_state and the | ||
| 27 | scheduler hot paths can touch op state without knowing the concrete | ||
| 28 | socket/acceptor types. | ||
| 29 | |||
| 30 | @see coro_op, reactor_op | ||
| 31 | */ | ||
| 32 | struct reactor_op_base : coro_op | ||
| 33 | { | ||
| 34 | /// Errno from the last I/O attempt. | ||
| 35 | int errn = 0; | ||
| 36 | |||
| 37 | /// Bytes transferred on success. | ||
| 38 | std::size_t bytes_transferred = 0; | ||
| 39 | |||
| 40 | // cancelled, impl_ptr, and request_cancel() are inherited from coro_op. | ||
| 41 | |||
| 42 | /// Record the result of an I/O attempt. | ||
| 43 | 102180x | void complete(int err, std::size_t bytes) noexcept | |
| 44 | { | ||
| 45 | 102180x | errn = err; | |
| 46 | 102180x | bytes_transferred = bytes; | |
| 47 | 102180x | } | |
| 48 | |||
| 49 | /// Perform the I/O syscall (overridden by concrete op types). | ||
| 50 | ✗ | virtual void perform_io() noexcept {} | |
| 51 | |||
| 52 | /// Destroy without invoking — drop the keepalive (impl_ptr from coro_op). | ||
| 53 | ✗ | void destroy() override | |
| 54 | { | ||
| 55 | ✗ | impl_ptr.reset(); | |
| 56 | ✗ | } | |
| 57 | }; | ||
| 58 | |||
| 59 | } // namespace boost::corosio::detail | ||
| 60 | |||
| 61 | #endif // BOOST_COROSIO_NATIVE_DETAIL_REACTOR_REACTOR_OP_BASE_HPP | ||
| 62 |