annotate DEPENDENCIES/generic/include/boost/asio/detail/winrt_timer_scheduler.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 //
Chris@16 2 // detail/winrt_timer_scheduler.hpp
Chris@16 3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Chris@16 4 //
Chris@101 5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
Chris@16 6 //
Chris@16 7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
Chris@16 8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Chris@16 9 //
Chris@16 10
Chris@16 11 #ifndef BOOST_ASIO_DETAIL_WINRT_TIMER_SCHEDULER_HPP
Chris@16 12 #define BOOST_ASIO_DETAIL_WINRT_TIMER_SCHEDULER_HPP
Chris@16 13
Chris@16 14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 15 # pragma once
Chris@16 16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
Chris@16 17
Chris@16 18 #include <boost/asio/detail/config.hpp>
Chris@16 19
Chris@16 20 #if defined(BOOST_ASIO_WINDOWS_RUNTIME)
Chris@16 21
Chris@16 22 #include <cstddef>
Chris@16 23 #include <boost/asio/detail/event.hpp>
Chris@16 24 #include <boost/asio/detail/limits.hpp>
Chris@16 25 #include <boost/asio/detail/mutex.hpp>
Chris@16 26 #include <boost/asio/detail/op_queue.hpp>
Chris@16 27 #include <boost/asio/detail/thread.hpp>
Chris@16 28 #include <boost/asio/detail/timer_queue_base.hpp>
Chris@16 29 #include <boost/asio/detail/timer_queue_set.hpp>
Chris@16 30 #include <boost/asio/detail/wait_op.hpp>
Chris@16 31 #include <boost/asio/io_service.hpp>
Chris@16 32
Chris@16 33 #if defined(BOOST_ASIO_HAS_IOCP)
Chris@16 34 # include <boost/asio/detail/thread.hpp>
Chris@16 35 #endif // defined(BOOST_ASIO_HAS_IOCP)
Chris@16 36
Chris@16 37 #include <boost/asio/detail/push_options.hpp>
Chris@16 38
Chris@16 39 namespace boost {
Chris@16 40 namespace asio {
Chris@16 41 namespace detail {
Chris@16 42
Chris@16 43 class winrt_timer_scheduler
Chris@16 44 : public boost::asio::detail::service_base<winrt_timer_scheduler>
Chris@16 45 {
Chris@16 46 public:
Chris@16 47 // Constructor.
Chris@16 48 BOOST_ASIO_DECL winrt_timer_scheduler(boost::asio::io_service& io_service);
Chris@16 49
Chris@16 50 // Destructor.
Chris@16 51 BOOST_ASIO_DECL ~winrt_timer_scheduler();
Chris@16 52
Chris@16 53 // Destroy all user-defined handler objects owned by the service.
Chris@16 54 BOOST_ASIO_DECL void shutdown_service();
Chris@16 55
Chris@16 56 // Recreate internal descriptors following a fork.
Chris@16 57 BOOST_ASIO_DECL void fork_service(
Chris@16 58 boost::asio::io_service::fork_event fork_ev);
Chris@16 59
Chris@16 60 // Initialise the task. No effect as this class uses its own thread.
Chris@16 61 BOOST_ASIO_DECL void init_task();
Chris@16 62
Chris@16 63 // Add a new timer queue to the reactor.
Chris@16 64 template <typename Time_Traits>
Chris@16 65 void add_timer_queue(timer_queue<Time_Traits>& queue);
Chris@16 66
Chris@16 67 // Remove a timer queue from the reactor.
Chris@16 68 template <typename Time_Traits>
Chris@16 69 void remove_timer_queue(timer_queue<Time_Traits>& queue);
Chris@16 70
Chris@16 71 // Schedule a new operation in the given timer queue to expire at the
Chris@16 72 // specified absolute time.
Chris@16 73 template <typename Time_Traits>
Chris@16 74 void schedule_timer(timer_queue<Time_Traits>& queue,
Chris@16 75 const typename Time_Traits::time_type& time,
Chris@16 76 typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op);
Chris@16 77
Chris@16 78 // Cancel the timer operations associated with the given token. Returns the
Chris@16 79 // number of operations that have been posted or dispatched.
Chris@16 80 template <typename Time_Traits>
Chris@16 81 std::size_t cancel_timer(timer_queue<Time_Traits>& queue,
Chris@16 82 typename timer_queue<Time_Traits>::per_timer_data& timer,
Chris@16 83 std::size_t max_cancelled = (std::numeric_limits<std::size_t>::max)());
Chris@16 84
Chris@16 85 private:
Chris@16 86 // Run the select loop in the thread.
Chris@16 87 BOOST_ASIO_DECL void run_thread();
Chris@16 88
Chris@16 89 // Entry point for the select loop thread.
Chris@16 90 BOOST_ASIO_DECL static void call_run_thread(winrt_timer_scheduler* reactor);
Chris@16 91
Chris@16 92 // Helper function to add a new timer queue.
Chris@16 93 BOOST_ASIO_DECL void do_add_timer_queue(timer_queue_base& queue);
Chris@16 94
Chris@16 95 // Helper function to remove a timer queue.
Chris@16 96 BOOST_ASIO_DECL void do_remove_timer_queue(timer_queue_base& queue);
Chris@16 97
Chris@16 98 // The io_service implementation used to post completions.
Chris@16 99 io_service_impl& io_service_;
Chris@16 100
Chris@16 101 // Mutex used to protect internal variables.
Chris@16 102 boost::asio::detail::mutex mutex_;
Chris@16 103
Chris@16 104 // Event used to wake up background thread.
Chris@16 105 boost::asio::detail::event event_;
Chris@16 106
Chris@16 107 // The timer queues.
Chris@16 108 timer_queue_set timer_queues_;
Chris@16 109
Chris@16 110 // The background thread that is waiting for timers to expire.
Chris@16 111 boost::asio::detail::thread* thread_;
Chris@16 112
Chris@16 113 // Does the background thread need to stop.
Chris@16 114 bool stop_thread_;
Chris@16 115
Chris@16 116 // Whether the service has been shut down.
Chris@16 117 bool shutdown_;
Chris@16 118 };
Chris@16 119
Chris@16 120 } // namespace detail
Chris@16 121 } // namespace asio
Chris@16 122 } // namespace boost
Chris@16 123
Chris@16 124 #include <boost/asio/detail/pop_options.hpp>
Chris@16 125
Chris@16 126 #include <boost/asio/detail/impl/winrt_timer_scheduler.hpp>
Chris@16 127 #if defined(BOOST_ASIO_HEADER_ONLY)
Chris@16 128 # include <boost/asio/detail/impl/winrt_timer_scheduler.ipp>
Chris@16 129 #endif // defined(BOOST_ASIO_HEADER_ONLY)
Chris@16 130
Chris@16 131 #endif // defined(BOOST_ASIO_WINDOWS_RUNTIME)
Chris@16 132
Chris@16 133 #endif // BOOST_ASIO_DETAIL_WINRT_TIMER_SCHEDULER_HPP