Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:28:35

0001 //
0002 // detail/impl/timer_queue_set.ipp
0003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0004 //
0005 // Copyright (c) 2003-2023 Christopher M. Kohlhoff (chris at kohlhoff dot com)
0006 //
0007 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0009 //
0010 
0011 #ifndef BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_SET_IPP
0012 #define BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_SET_IPP
0013 
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
0017 
0018 #include <boost/asio/detail/config.hpp>
0019 #include <boost/asio/detail/timer_queue_set.hpp>
0020 
0021 #include <boost/asio/detail/push_options.hpp>
0022 
0023 namespace boost {
0024 namespace asio {
0025 namespace detail {
0026 
0027 timer_queue_set::timer_queue_set()
0028   : first_(0)
0029 {
0030 }
0031 
0032 void timer_queue_set::insert(timer_queue_base* q)
0033 {
0034   q->next_ = first_;
0035   first_ = q;
0036 }
0037 
0038 void timer_queue_set::erase(timer_queue_base* q)
0039 {
0040   if (first_)
0041   {
0042     if (q == first_)
0043     {
0044       first_ = q->next_;
0045       q->next_ = 0;
0046       return;
0047     }
0048 
0049     for (timer_queue_base* p = first_; p->next_; p = p->next_)
0050     {
0051       if (p->next_ == q)
0052       {
0053         p->next_ = q->next_;
0054         q->next_ = 0;
0055         return;
0056       }
0057     }
0058   }
0059 }
0060 
0061 bool timer_queue_set::all_empty() const
0062 {
0063   for (timer_queue_base* p = first_; p; p = p->next_)
0064     if (!p->empty())
0065       return false;
0066   return true;
0067 }
0068 
0069 long timer_queue_set::wait_duration_msec(long max_duration) const
0070 {
0071   long min_duration = max_duration;
0072   for (timer_queue_base* p = first_; p; p = p->next_)
0073     min_duration = p->wait_duration_msec(min_duration);
0074   return min_duration;
0075 }
0076 
0077 long timer_queue_set::wait_duration_usec(long max_duration) const
0078 {
0079   long min_duration = max_duration;
0080   for (timer_queue_base* p = first_; p; p = p->next_)
0081     min_duration = p->wait_duration_usec(min_duration);
0082   return min_duration;
0083 }
0084 
0085 void timer_queue_set::get_ready_timers(op_queue<operation>& ops)
0086 {
0087   for (timer_queue_base* p = first_; p; p = p->next_)
0088     p->get_ready_timers(ops);
0089 }
0090 
0091 void timer_queue_set::get_all_timers(op_queue<operation>& ops)
0092 {
0093   for (timer_queue_base* p = first_; p; p = p->next_)
0094     p->get_all_timers(ops);
0095 }
0096 
0097 } // namespace detail
0098 } // namespace asio
0099 } // namespace boost
0100 
0101 #include <boost/asio/detail/pop_options.hpp>
0102 
0103 #endif // BOOST_ASIO_DETAIL_IMPL_TIMER_QUEUE_SET_IPP