src/corosio/src/detail/posix/signals.hpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 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_DETAIL_POSIX_SIGNALS_HPP | ||
| 11 | #define BOOST_COROSIO_DETAIL_POSIX_SIGNALS_HPP | ||
| 12 | |||
| 13 | #include <boost/corosio/detail/platform.hpp> | ||
| 14 | |||
| 15 | #if BOOST_COROSIO_POSIX | ||
| 16 | |||
| 17 | #include <boost/corosio/detail/config.hpp> | ||
| 18 | #include <boost/corosio/signal_set.hpp> | ||
| 19 | #include <boost/capy/ex/execution_context.hpp> | ||
| 20 | |||
| 21 | /* | ||
| 22 | POSIX Signal Service | ||
| 23 | ==================== | ||
| 24 | |||
| 25 | This header declares the abstract signal service interface. The concrete | ||
| 26 | implementation (posix_signals_impl) is in signals.cpp. | ||
| 27 | |||
| 28 | This follows the timer_service pattern: | ||
| 29 | - posix_signals is an abstract base class (no scheduler dependency) | ||
| 30 | - posix_signals_impl is the concrete implementation | ||
| 31 | - get_signal_service(ctx, sched) creates the service with scheduler ref | ||
| 32 | |||
| 33 | See signals.cpp for the full implementation overview. | ||
| 34 | */ | ||
| 35 | |||
| 36 | namespace boost::corosio::detail { | ||
| 37 | |||
| 38 | struct scheduler; | ||
| 39 | |||
| 40 | //------------------------------------------------------------------------------ | ||
| 41 | |||
| 42 | /** Abstract signal service for POSIX backends. | ||
| 43 | |||
| 44 | This is the base class that defines the interface. The concrete | ||
| 45 | implementation (posix_signals_impl) is created via get_signal_service() | ||
| 46 | which passes the scheduler reference. | ||
| 47 | */ | ||
| 48 | class posix_signals : public capy::execution_context::service | ||
| 49 | { | ||
| 50 | public: | ||
| 51 | /** Create a new signal set implementation. */ | ||
| 52 | virtual signal_set::signal_set_impl& create_impl() = 0; | ||
| 53 | |||
| 54 | protected: | ||
| 55 | 336 | posix_signals() = default; | |
| 56 | }; | ||
| 57 | |||
| 58 | //------------------------------------------------------------------------------ | ||
| 59 | |||
| 60 | /** Get or create the signal service for the given context. | ||
| 61 | |||
| 62 | This function is called by the concrete scheduler during initialization | ||
| 63 | to create the signal service with a reference to itself. | ||
| 64 | |||
| 65 | @param ctx Reference to the owning execution_context. | ||
| 66 | @param sched Reference to the scheduler for posting completions. | ||
| 67 | @return Reference to the signal service. | ||
| 68 | */ | ||
| 69 | posix_signals& | ||
| 70 | get_signal_service(capy::execution_context& ctx, scheduler& sched); | ||
| 71 | |||
| 72 | } // namespace boost::corosio::detail | ||
| 73 | |||
| 74 | #endif // BOOST_COROSIO_POSIX | ||
| 75 | |||
| 76 | #endif // BOOST_COROSIO_DETAIL_POSIX_SIGNALS_HPP | ||
| 77 |