]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/asio/detail/impl/epoll_reactor.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / boost / asio / detail / impl / epoll_reactor.hpp
CommitLineData
7c673cae
FG
1//
2// detail/impl/epoll_reactor.hpp
3// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4//
f67539c2 5// Copyright (c) 2003-2020 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7c673cae
FG
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
22namespace boost {
23namespace asio {
24namespace detail {
25
26template <typename Time_Traits>
27void epoll_reactor::add_timer_queue(timer_queue<Time_Traits>& queue)
28{
29 do_add_timer_queue(queue);
30}
31
32template <typename Time_Traits>
33void epoll_reactor::remove_timer_queue(timer_queue<Time_Traits>& queue)
34{
35 do_remove_timer_queue(queue);
36}
37
38template <typename Time_Traits>
39void 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 {
b32b8144 47 scheduler_.post_immediate_completion(op, false);
7c673cae
FG
48 return;
49 }
50
51 bool earliest = queue.enqueue_timer(time, timer, op);
b32b8144 52 scheduler_.work_started();
7c673cae
FG
53 if (earliest)
54 update_timeout();
55}
56
57template <typename Time_Traits>
58std::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();
b32b8144 66 scheduler_.post_deferred_completions(ops);
7c673cae
FG
67 return n;
68}
69
b32b8144
FG
70template <typename Time_Traits>
71void 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
7c673cae
FG
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