Statistics
| Revision:

root / tmp / org.txm.statsengine.r.core.win32 / res / win32 / library / BH / include / boost / asio / detail / winrt_timer_scheduler.hpp @ 2486

History | View | Annotate | Download (4.1 kB)

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