Realistic 3D camera system
3D camera system components
winrt_timer_scheduler.hpp
Go to the documentation of this file.
1 //
2 // detail/impl/winrt_timer_scheduler.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef ASIO_DETAIL_IMPL_WINRT_TIMER_SCHEDULER_HPP
12 #define ASIO_DETAIL_IMPL_WINRT_TIMER_SCHEDULER_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
19 
20 #if defined(ASIO_WINDOWS_RUNTIME)
21 
23 
24 namespace asio {
25 namespace detail {
26 
27 template <typename Time_Traits>
28 void winrt_timer_scheduler::add_timer_queue(timer_queue<Time_Traits>& queue)
29 {
30  do_add_timer_queue(queue);
31 }
32 
33 // Remove a timer queue from the reactor.
34 template <typename Time_Traits>
35 void winrt_timer_scheduler::remove_timer_queue(timer_queue<Time_Traits>& queue)
36 {
37  do_remove_timer_queue(queue);
38 }
39 
40 template <typename Time_Traits>
41 void winrt_timer_scheduler::schedule_timer(timer_queue<Time_Traits>& queue,
42  const typename Time_Traits::time_type& time,
43  typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op)
44 {
46 
47  if (shutdown_)
48  {
49  io_service_.post_immediate_completion(op, false);
50  return;
51  }
52 
53  bool earliest = queue.enqueue_timer(time, timer, op);
54  io_service_.work_started();
55  if (earliest)
56  event_.signal(lock);
57 }
58 
59 template <typename Time_Traits>
60 std::size_t winrt_timer_scheduler::cancel_timer(timer_queue<Time_Traits>& queue,
61  typename timer_queue<Time_Traits>::per_timer_data& timer,
62  std::size_t max_cancelled)
63 {
65  op_queue<operation> ops;
66  std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
67  lock.unlock();
68  io_service_.post_deferred_completions(ops);
69  return n;
70 }
71 
72 } // namespace detail
73 } // namespace asio
74 
76 
77 #endif // defined(ASIO_WINDOWS_RUNTIME)
78 
79 #endif // ASIO_DETAIL_IMPL_WINRT_TIMER_SCHEDULER_HPP