]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/asio/detail/impl/epoll_reactor.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / asio / detail / impl / epoll_reactor.hpp
1 //
2 // detail/impl/epoll_reactor.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2017 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 scheduler_.post_immediate_completion(op, false);
48 return;
49 }
50
51 bool earliest = queue.enqueue_timer(time, timer, op);
52 scheduler_.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 scheduler_.post_deferred_completions(ops);
67 return n;
68 }
69
70 template <typename Time_Traits>
71 void epoll_reactor::move_timer(timer_queue<Time_Traits>& queue,
72 typename timer_queue<Time_Traits>::per_timer_data& target,
73 typename timer_queue<Time_Traits>::per_timer_data& source)
74 {
75 mutex::scoped_lock lock(mutex_);
76 op_queue<operation> ops;
77 queue.cancel_timer(target, ops);
78 queue.move_timer(target, source);
79 lock.unlock();
80 scheduler_.post_deferred_completions(ops);
81 }
82
83 } // namespace detail
84 } // namespace asio
85 } // namespace boost
86
87 #include <boost/asio/detail/pop_options.hpp>
88
89 #endif // defined(BOOST_ASIO_HAS_EPOLL)
90
91 #endif // BOOST_ASIO_DETAIL_IMPL_EPOLL_REACTOR_HPP