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