libassa  3.5.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TimerQueue.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //------------------------------------------------------------------------------
3 // TimerQueue.h
4 //------------------------------------------------------------------------------
5 // Copyright (c) 1999,2005 by Vladislav Grinchenko
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //------------------------------------------------------------------------------
12 // Created: 07/28/1999
13 //------------------------------------------------------------------------------
14 #ifndef TIMER_QUEUE_H
15 #define TIMER_QUEUE_H
16 
17 #include <time.h>
18 #include <sys/time.h>
19 #include <unistd.h>
20 
21 #include "assa/Logger.h"
22 #include "assa/EventHandler.h"
23 #include "assa/Timer.h"
24 #include "assa/PriorityQueue.h"
25 
26 namespace ASSA {
27 
28 typedef unsigned long TimerId;
29 
36 {
37 public:
39  TimerQueue ();
40 
42  ~TimerQueue ();
43 
47  bool isEmpty ();
48 
62  const TimeVal& tv_,
63  const TimeVal& delta_,
64  const std::string& name_);
65 
70  int remove (EventHandler* eh_);
71 
76  bool remove (TimerId tid_);
77 
84  int expire (const TimeVal& tv_);
85 
87  TimeVal& top (void);
88 
90  void dump (void);
91 
92 private:
95 };
96 
97 //------------------------------------------------------------------------------
98 // Inline functions
99 //------------------------------------------------------------------------------
100 
101 inline
104 {
105  trace("TimerQueue::TimerQueue");
106 }
107 
108 inline bool
111 {
112  return m_queue.size () == 0;
113 }
114 
115 inline TimeVal&
117 top (void)
118 {
119  return (TimeVal&) m_queue.top ()->getExpirationTime ();
120 }
121 
122 } // end namespace ASSA
123 
124 #endif /* TIMER_QUEUE_H */