#include <events.hh>
Collaboration diagram for EventQueue:

Public Member Functions | |
| EventQueue () | |
| virtual | ~EventQueue () |
| virtual void | eqAddAfter (handle hdl, void *payload, int delay_msec) |
| QueueEvent * | eqPop () |
| QueueEvent * | eqFindEvent (handle hdl) |
| void | eqNextTimer (struct timeval *tv) |
| virtual bool | eqRemove (handle hdl) |
Private Member Functions | |
| int | eqTopInPast () |
| void | eqPrint () |
| bool | eqRemoveEvent (QueueEvent *e) |
| QueueEvent * | eqFindNextEvent (handle hdl, QueueEvent *e) |
| void | eqAdd (QueueEvent *e) |
| void | setDelay (QueueEvent *e, int delay_msec) |
| int | randDelay (int timer[2]) |
| int | eventCmp (QueueEvent *x, QueueEvent *y) |
Private Attributes | |
| QueueEvent * | head_ |
|
|
Definition at line 66 of file events.hh. References head_.
00066 {
00067 // Empty
00068 head_ = NULL;
00069 };
|
|
|
Definition at line 70 of file events.hh.
00070 {
00071 // Empty
00072 };
|
|
|
Definition at line 76 of file events.cc. References eventCmp(), head_, and QueueEvent::next_. Referenced by eqAddAfter().
00077 {
00078 QueueEvent *ptr = head_;
00079 QueueEvent *last = ptr;
00080
00081 while (ptr && (eventCmp(e, ptr) > 0)){
00082 last = ptr;
00083 ptr = ptr->next_;
00084 }
00085 if (last == ptr){
00086 e->next_ = head_;
00087 head_ = e;
00088 }
00089 else{
00090 e->next_ = ptr;
00091 last->next_ = e;
00092 }
00093 }
|
Here is the call graph for this function:

|
||||||||||||||||
|
Definition at line 122 of file events.cc. References eqAdd(), QueueEvent::handle_, QueueEvent::payload_, and setDelay(). Referenced by TimerManager::addTimer(), and TimerManager::executeNextTimer().
00123 {
00124 QueueEvent *e = new QueueEvent;
00125
00126 e->handle_ = hdl;
00127 e->payload_ = payload;
00128 setDelay(e, delay_msec);
00129 eqAdd(e);
00130 }
|
Here is the call graph for this function:

|
|
Definition at line 106 of file events.cc. References eqFindNextEvent(), and head_. Referenced by eqRemove(), and TimerManager::removeTimer().
00107 {
00108 return eqFindNextEvent(hdl, head_);
00109 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 111 of file events.cc. References QueueEvent::handle_, and QueueEvent::next_. Referenced by eqFindEvent().
|
|
|
Definition at line 138 of file events.cc. References GetTime(), head_, MAXVALUE, TimevalSub(), and QueueEvent::tv_. Referenced by TimerManager::nextTimerTime().
|
Here is the call graph for this function:

|
|
Definition at line 95 of file events.cc. References head_, and QueueEvent::next_. Referenced by TimerManager::executeNextTimer().
00096 {
00097 QueueEvent *e = head_;
00098
00099 if (e){
00100 head_ = head_->next_;
00101 e->next_ = NULL;
00102 }
00103 return e;
00104 }
|
|
|
Definition at line 163 of file events.cc. References QueueEvent::handle_, head_, QueueEvent::next_, and QueueEvent::tv_.
|
|
|
Definition at line 201 of file events.cc. References eqFindEvent(), and eqRemoveEvent(). Referenced by TimerManager::removeTimer().
00202 {
00203 QueueEvent *e = NULL;
00204
00205 // Look in the event queue for an event with handle hdl
00206 e = eqFindEvent(hdl);
00207
00208 // If found, delete event
00209 if (e){
00210 return (eqRemoveEvent(e));
00211 }
00212
00213 return false;
00214 }
|
Here is the call graph for this function:

|
|
Definition at line 173 of file events.cc. References head_, and QueueEvent::next_. Referenced by eqRemove().
00174 {
00175 QueueEvent *ce, *pe;
00176
00177 if (e){
00178 if (head_ == e){
00179 head_ = e->next_;
00180 return true;
00181 }
00182
00183 pe = head_;
00184 ce = head_->next_;
00185
00186 while (ce){
00187 if (ce == e){
00188 pe->next_ = e->next_;
00189 return true;
00190 }
00191 else{
00192 pe = ce;
00193 ce = ce->next_;
00194 }
00195 }
00196 }
00197
00198 return false;
00199 }
|
|
|
Definition at line 152 of file events.cc. References GetTime(), head_, TimevalCmp(), and QueueEvent::tv_.
00153 {
00154 struct timeval now;
00155
00156 if (head_){
00157 GetTime(&now);
00158 return (TimevalCmp(&(head_->tv_), &now) <= 0);
00159 }
00160 return 0;
00161 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 71 of file events.cc. References TimevalCmp(), and QueueEvent::tv_. Referenced by eqAdd().
00072 {
00073 return TimevalCmp(&(x->tv_), &(y->tv_));
00074 }
|
Here is the call graph for this function:

|
|
Definition at line 219 of file events.cc. References GetRand(), and RAND_MAX.
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 132 of file events.cc. References GetTime(), TimevalAddusecs(), and QueueEvent::tv_. Referenced by eqAddAfter().
00133 {
00134 GetTime(&(e->tv_));
00135 TimevalAddusecs(&(e->tv_), delay_msec * 1000);
00136 }
|
Here is the call graph for this function:

|
|
Definition at line 102 of file events.hh. Referenced by eqAdd(), eqFindEvent(), eqNextTimer(), eqPop(), eqPrint(), eqRemoveEvent(), eqTopInPast(), and EventQueue(). |
1.3.3