include/boost/corosio/native/detail/reactor/reactor_op_base.hpp
100.0% Lines (10 / 10)
-% Branches (0 / 0)
100.0% Functions (4 / 4)
Functions (4)
Function
Calls
Lines
Branches
Blocks
boost::corosio::detail::reactor_op_base::reactor_op_base()
:32
59527x
100.0%
–
100.0%
boost::corosio::detail::reactor_op_base::~reactor_op_base()
:32
59523x
100.0%
–
100.0%
boost::corosio::detail::reactor_op_base::complete(int, unsigned long)
:43
364497x
100.0%
–
100.0%
boost::corosio::detail::reactor_op_base::destroy()
:54
1292x
100.0%
–
100.0%
| Line | Branch | 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, object_ref_ 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 | 59527x | struct reactor_op_base : coro_op | ||
| 33 | { | |||
| 34 | /// Errno from the last I/O attempt. | |||
| 35 | 59527x | int errn = 0; | ||
| 36 | ||||
| 37 | /// Bytes transferred on success. | |||
| 38 | 59527x | std::size_t bytes_transferred = 0; | ||
| 39 | ||||
| 40 | // cancelled, object_ref_, and request_cancel() are inherited from coro_op. | |||
| 41 | ||||
| 42 | /// Record the result of an I/O attempt. | |||
| 43 | 364497x | void complete(int err, std::size_t bytes) noexcept | ||
| 44 | { | |||
| 45 | 364497x | errn = err; | ||
| 46 | 364497x | bytes_transferred = bytes; | ||
| 47 | 364497x | } | ||
| 48 | ||||
| 49 | /// Perform the I/O syscall (implemented by concrete op types). | |||
| 50 | virtual void perform_io() noexcept = 0; | |||
| 51 | ||||
| 52 | /// Destroy without invoking: the drained op abandons the coroutine | |||
| 53 | /// it holds. | |||
| 54 | 1292x | void destroy() override | ||
| 55 | { | |||
| 56 | 1292x | destroy_awaiting(); | ||
| 57 | 1292x | } | ||
| 58 | }; | |||
| 59 | ||||
| 60 | } // namespace boost::corosio::detail | |||
| 61 | ||||
| 62 | #endif // BOOST_COROSIO_NATIVE_DETAIL_REACTOR_REACTOR_OP_BASE_HPP | |||
| 63 |