/home/vlg/develop/libASSA/libassa/assa/TimerQueue.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //------------------------------------------------------------------------------
00003 //                          TimerQueue.h
00004 //------------------------------------------------------------------------------
00005 //  Copyright (c) 1999,2005 by Vladislav Grinchenko
00006 //
00007 //  This library is free software; you can redistribute it and/or
00008 //  modify it under the terms of the GNU Library General Public
00009 //  License as published by the Free Software Foundation; either
00010 //  version 2 of the License, or (at your option) any later version.
00011 //------------------------------------------------------------------------------
00012 //  Created: 07/28/1999
00013 //------------------------------------------------------------------------------
00014 #ifndef TIMER_QUEUE_H
00015 #define TIMER_QUEUE_H
00016 
00017 #include <time.h>
00018 #include <sys/time.h>
00019 #include <unistd.h>
00020 
00021 #include "assa/Logger.h"
00022 #include "assa/EventHandler.h"
00023 #include "assa/Timer.h"
00024 #include "assa/PriorityQueue.h"
00025 
00026 namespace ASSA {
00027 
00028 typedef unsigned long TimerId;
00029 
00035 class TimerQueue
00036 {
00037 public:
00039     TimerQueue ();
00040 
00042     ~TimerQueue ();
00043 
00047     bool isEmpty ();
00048 
00061     TimerId insert (EventHandler* eh_, 
00062                     const TimeVal& tv_, 
00063                     const TimeVal& delta_,
00064                     const std::string& name_);
00065 
00070     int remove (EventHandler* eh_);
00071 
00076     bool remove (TimerId tid_);
00077 
00084     int expire (const TimeVal& tv_);
00085 
00087     TimeVal& top (void);
00088 
00090     void dump (void);
00091 
00092 private:
00094     PriorityQueue <Timer*, TimerCompare> m_queue;
00095 };
00096 
00097 //------------------------------------------------------------------------------
00098 // Inline functions
00099 //------------------------------------------------------------------------------
00100 
00101 inline
00102 TimerQueue::
00103 TimerQueue () 
00104 {
00105     trace("TimerQueue::TimerQueue");
00106 }
00107 
00108 inline bool
00109 TimerQueue::
00110 isEmpty ()
00111 { 
00112     return m_queue.size () == 0;
00113 }
00114 
00115 inline TimeVal&
00116 TimerQueue::
00117 top (void)
00118 {
00119     return (TimeVal&) m_queue.top ()->getExpirationTime ();
00120 }
00121 
00122 } // end namespace ASSA
00123 
00124 #endif /* TIMER_QUEUE_H */  

Generated on Sun Aug 13 15:08:00 2006 for libassa by  doxygen 1.4.6