Line data Source code
1 : //
2 : // Copyright (c) 2025 Vinnie Falco (vinnie dot falco at gmail dot com)
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_SCHEDULER_HPP
11 : #define BOOST_COROSIO_DETAIL_SCHEDULER_HPP
12 :
13 : #include <boost/corosio/detail/config.hpp>
14 : #include <boost/capy/coro.hpp>
15 :
16 : #include <cstddef>
17 :
18 : namespace boost::corosio::detail {
19 :
20 : class scheduler_op;
21 :
22 : struct scheduler
23 : {
24 304 : virtual ~scheduler() = default;
25 : virtual void post(capy::coro) const = 0;
26 : virtual void post(scheduler_op*) const = 0;
27 :
28 : /** Notify scheduler of pending work (for executor use).
29 : When the count reaches zero, the scheduler stops.
30 : */
31 : virtual void on_work_started() noexcept = 0;
32 : virtual void on_work_finished() noexcept = 0;
33 :
34 : /** Notify scheduler of pending I/O work (for services use).
35 : Unlike on_work_finished, work_finished does not stop the scheduler
36 : when the count reaches zero - it only wakes blocked threads.
37 : */
38 : virtual void work_started() const noexcept = 0;
39 : virtual void work_finished() const noexcept = 0;
40 :
41 : virtual bool running_in_this_thread() const noexcept = 0;
42 : virtual void stop() = 0;
43 : virtual bool stopped() const noexcept = 0;
44 : virtual void restart() = 0;
45 : virtual std::size_t run() = 0;
46 : virtual std::size_t run_one() = 0;
47 : virtual std::size_t wait_one(long usec) = 0;
48 : virtual std::size_t poll() = 0;
49 : virtual std::size_t poll_one() = 0;
50 : };
51 :
52 : } // namespace boost::corosio::detail
53 :
54 : #endif
|