Realistic 3D camera system
3D camera system components
epoll_reactor.hpp
Go to the documentation of this file.
1 //
2 // detail/impl/epoll_reactor.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_EPOLL_REACTOR_HPP
12 #define ASIO_DETAIL_IMPL_EPOLL_REACTOR_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #if defined(ASIO_HAS_EPOLL)
19 
21 
22 namespace asio {
23 namespace detail {
24 
25 template <typename Time_Traits>
26 void epoll_reactor::add_timer_queue(timer_queue<Time_Traits>& queue)
27 {
28  do_add_timer_queue(queue);
29 }
30 
31 template <typename Time_Traits>
32 void epoll_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue)
33 {
34  do_remove_timer_queue(queue);
35 }
36 
37 template <typename Time_Traits>
38 void epoll_reactor::schedule_timer(timer_queue<Time_Traits>& queue,
39  const typename Time_Traits::time_type& time,
40  typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op)
41 {
42  mutex::scoped_lock lock(mutex_);
43 
44  if (shutdown_)
45  {
46  io_service_.post_immediate_completion(op, false);
47  return;
48  }
49 
50  bool earliest = queue.enqueue_timer(time, timer, op);
51  io_service_.work_started();
52  if (earliest)
53  update_timeout();
54 }
55 
56 template <typename Time_Traits>
57 std::size_t epoll_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
58  typename timer_queue<Time_Traits>::per_timer_data& timer,
59  std::size_t max_cancelled)
60 {
61  mutex::scoped_lock lock(mutex_);
62  op_queue<operation> ops;
63  std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
64  lock.unlock();
65  io_service_.post_deferred_completions(ops);
66  return n;
67 }
68 
69 } // namespace detail
70 } // namespace asio
71 
73 
74 #endif // defined(ASIO_HAS_EPOLL)
75 
76 #endif // ASIO_DETAIL_IMPL_EPOLL_REACTOR_HPP
asio::detail::scoped_lock< null_mutex > scoped_lock
Definition: null_mutex.hpp:34