]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/asio/include/boost/asio/detail/impl/timer_queue_set.ipp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / asio / include / boost / asio / detail / impl / timer_queue_set.ipp
1 //
2 // detail/impl/timer_queue_set.ipp
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_TIMER_QUEUE_SET_IPP
12 #define BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_SET_IPP
13
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/detail/timer_queue_set.hpp>
20
21 #include <boost/asio/detail/push_options.hpp>
22
23 namespace boost {
24 namespace asio {
25 namespace detail {
26
27 timer_queue_set::timer_queue_set()
28 : first_(0)
29 {
30 }
31
32 void timer_queue_set::insert(timer_queue_base* q)
33 {
34 q->next_ = first_;
35 first_ = q;
36 }
37
38 void timer_queue_set::erase(timer_queue_base* q)
39 {
40 if (first_)
41 {
42 if (q == first_)
43 {
44 first_ = q->next_;
45 q->next_ = 0;
46 return;
47 }
48
49 for (timer_queue_base* p = first_; p->next_; p = p->next_)
50 {
51 if (p->next_ == q)
52 {
53 p->next_ = q->next_;
54 q->next_ = 0;
55 return;
56 }
57 }
58 }
59 }
60
61 bool timer_queue_set::all_empty() const
62 {
63 for (timer_queue_base* p = first_; p; p = p->next_)
64 if (!p->empty())
65 return false;
66 return true;
67 }
68
69 long timer_queue_set::wait_duration_msec(long max_duration) const
70 {
71 long min_duration = max_duration;
72 for (timer_queue_base* p = first_; p; p = p->next_)
73 min_duration = p->wait_duration_msec(min_duration);
74 return min_duration;
75 }
76
77 long timer_queue_set::wait_duration_usec(long max_duration) const
78 {
79 long min_duration = max_duration;
80 for (timer_queue_base* p = first_; p; p = p->next_)
81 min_duration = p->wait_duration_usec(min_duration);
82 return min_duration;
83 }
84
85 void timer_queue_set::get_ready_timers(op_queue<operation>& ops)
86 {
87 for (timer_queue_base* p = first_; p; p = p->next_)
88 p->get_ready_timers(ops);
89 }
90
91 void timer_queue_set::get_all_timers(op_queue<operation>& ops)
92 {
93 for (timer_queue_base* p = first_; p; p = p->next_)
94 p->get_all_timers(ops);
95 }
96
97 } // namespace detail
98 } // namespace asio
99 } // namespace boost
100
101 #include <boost/asio/detail/pop_options.hpp>
102
103 #endif // BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_SET_IPP