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