File indexing completed on 2025-01-18 09:28:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_DETAIL_WINRT_TIMER_SCHEDULER_HPP
0012 #define BOOST_ASIO_DETAIL_WINRT_TIMER_SCHEDULER_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019
0020 #if defined(BOOST_ASIO_WINDOWS_RUNTIME)
0021
0022 #include <cstddef>
0023 #include <boost/asio/detail/event.hpp>
0024 #include <boost/asio/detail/limits.hpp>
0025 #include <boost/asio/detail/mutex.hpp>
0026 #include <boost/asio/detail/op_queue.hpp>
0027 #include <boost/asio/detail/thread.hpp>
0028 #include <boost/asio/detail/timer_queue_base.hpp>
0029 #include <boost/asio/detail/timer_queue_set.hpp>
0030 #include <boost/asio/detail/wait_op.hpp>
0031 #include <boost/asio/execution_context.hpp>
0032
0033 #if defined(BOOST_ASIO_HAS_IOCP)
0034 # include <boost/asio/detail/win_iocp_io_context.hpp>
0035 #else
0036 # include <boost/asio/detail/scheduler.hpp>
0037 #endif
0038
0039 #if defined(BOOST_ASIO_HAS_IOCP)
0040 # include <boost/asio/detail/thread.hpp>
0041 #endif
0042
0043 #include <boost/asio/detail/push_options.hpp>
0044
0045 namespace boost {
0046 namespace asio {
0047 namespace detail {
0048
0049 class winrt_timer_scheduler
0050 : public execution_context_service_base<winrt_timer_scheduler>
0051 {
0052 public:
0053
0054 BOOST_ASIO_DECL winrt_timer_scheduler(execution_context& context);
0055
0056
0057 BOOST_ASIO_DECL ~winrt_timer_scheduler();
0058
0059
0060 BOOST_ASIO_DECL void shutdown();
0061
0062
0063 BOOST_ASIO_DECL void notify_fork(execution_context::fork_event fork_ev);
0064
0065
0066 BOOST_ASIO_DECL void init_task();
0067
0068
0069 template <typename Time_Traits>
0070 void add_timer_queue(timer_queue<Time_Traits>& queue);
0071
0072
0073 template <typename Time_Traits>
0074 void remove_timer_queue(timer_queue<Time_Traits>& queue);
0075
0076
0077
0078 template <typename Time_Traits>
0079 void schedule_timer(timer_queue<Time_Traits>& queue,
0080 const typename Time_Traits::time_type& time,
0081 typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op);
0082
0083
0084
0085 template <typename Time_Traits>
0086 std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
0087 typename timer_queue<Time_Traits>::per_timer_data& timer,
0088 std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
0089
0090
0091 template <typename Time_Traits>
0092 void move_timer(timer_queue<Time_Traits>& queue,
0093 typename timer_queue<Time_Traits>::per_timer_data& to,
0094 typename timer_queue<Time_Traits>::per_timer_data& from);
0095
0096 private:
0097
0098 BOOST_ASIO_DECL void run_thread();
0099
0100
0101 BOOST_ASIO_DECL static void call_run_thread(winrt_timer_scheduler* reactor);
0102
0103
0104 BOOST_ASIO_DECL void do_add_timer_queue(timer_queue_base& queue);
0105
0106
0107 BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue);
0108
0109
0110 #if defined(BOOST_ASIO_HAS_IOCP)
0111 typedef class win_iocp_io_context scheduler_impl;
0112 #else
0113 typedef class scheduler scheduler_impl;
0114 #endif
0115 scheduler_impl& scheduler_;
0116
0117
0118 boost::asio::detail::mutex mutex_;
0119
0120
0121 boost::asio::detail::event event_;
0122
0123
0124 timer_queue_set timer_queues_;
0125
0126
0127 boost::asio::detail::thread* thread_;
0128
0129
0130 bool stop_thread_;
0131
0132
0133 bool shutdown_;
0134 };
0135
0136 }
0137 }
0138 }
0139
0140 #include <boost/asio/detail/pop_options.hpp>
0141
0142 #include <boost/asio/detail/impl/winrt_timer_scheduler.hpp>
0143 #if defined(BOOST_ASIO_HEADER_ONLY)
0144 # include <boost/asio/detail/impl/winrt_timer_scheduler.ipp>
0145 #endif
0146
0147 #endif
0148
0149 #endif