]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/include/boost/asio/detail/impl/epoll_reactor.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / asio / include / boost / asio / detail / impl / epoll_reactor.hpp
1 //
2 // detail/impl/epoll_reactor.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2016 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 BOOST_ASIO_DETAIL_IMPL_EPOLL_REACTOR_HPP
12 #define BOOST_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(BOOST_ASIO_HAS_EPOLL)
19
20 #include <boost/asio/detail/push_options.hpp>
21
22 namespace boost {
23 namespace asio {
24 namespace detail {
25
26 template <typename Time_Traits>
27 void epoll_reactor::add_timer_queue(timer_queue<Time_Traits>& queue)
28 {
29 do_add_timer_queue(queue);
30 }
31
32 template <typename Time_Traits>
33 void epoll_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue)
34 {
35 do_remove_timer_queue(queue);
36 }
37
38 template <typename Time_Traits>
39 void epoll_reactor::schedule_timer(timer_queue<Time_Traits>& queue,
40 const typename Time_Traits::time_type& time,
41 typename timer_queue<Time_Traits>::per_timer_data& timer, wait_op* op)
42 {
43 mutex::scoped_lock lock(mutex_);
44
45 if (shutdown_)
46 {
47 io_service_.post_immediate_completion(op, false);
48 return;
49 }
50
51 bool earliest = queue.enqueue_timer(time, timer, op);
52 io_service_.work_started();
53 if (earliest)
54 update_timeout();
55 }
56
57 template <typename Time_Traits>
58 std::size_t epoll_reactor::cancel_timer(timer_queue<Time_Traits>& queue,
59 typename timer_queue<Time_Traits>::per_timer_data& timer,
60 std::size_t max_cancelled)
61 {
62 mutex::scoped_lock lock(mutex_);
63 op_queue<operation> ops;
64 std::size_t n = queue.cancel_timer(timer, ops, max_cancelled);
65 lock.unlock();
66 io_service_.post_deferred_completions(ops);
67 return n;
68 }
69
70 } // namespace detail
71 } // namespace asio
72 } // namespace boost
73
74 #include <boost/asio/detail/pop_options.hpp>
75
76 #endif // defined(BOOST_ASIO_HAS_EPOLL)
77
78 #endif // BOOST_ASIO_DETAIL_IMPL_EPOLL_REACTOR_HPP