#include <Timer.h>
Inheritance diagram for Timer::
Public Methods | |
void | addEvent (int millisec, void *(*func)(void *), void *arg, bool *set) |
This is used to execute a function sometime in the future. More... | |
virtual void | toStream (std::ostream &) |
Prints out the times of all scheduled events. More... | |
void | setName (string) |
Allows you to set a name for this timer, rpimarily for debugging purposes, since the timer resides in a separate thread, and there are multiple timers, it helps to know which is which. More... | |
string | getName () |
Get the name of the timer. More... | |
Protected Methods | |
Timer () | |
no one is allowed to create a timer object, only subclasses. More... | |
virtual | ~Timer () |
Destroy the Timer, and its associated thread. More... | |
void | timerThreadImpl () |
This is a thread that waits on the event at the head of the queue, and when the time comes for the event to be fired, it calls doAction() if the event is still valid. More... | |
virtual void | doAction (TimerNode *)=0 |
a Template Method, subclasses must override. More... | |
Static Protected Methods | |
void * | timerThread (void *) |
Thread function. More... | |
Protected Attributes | |
pthread_t | m_timerThreadId |
ID of the timer thread. More... | |
Condition | m_eventListSignal |
Signalled if there has been a change to the contents of the event list. More... | |
Mutex | m_eventListMutex |
Used to lock the event list. More... | |
list< TimerNode *> | m_eventList |
the event list. More... | |
bool | m_destroyed |
true if we want to destroy this object. More... | |
string | m_name |
the name of this timer. More... |
Events are registered using the "addEvent" function. Events can be cancelled by setting the boolean pointer passed in to addEvent to false.
Subclasses of Timer do different things with the function passed in as an event. The CallbackTimer executes the function in-line, while the ThreadSpawningTimer executes the function in a new thread.
Definition at line 14 of file Timer.h.
|
no one is allowed to create a timer object, only subclasses.
|
|
Destroy the Timer, and its associated thread.
|
|
This is used to execute a function sometime in the future. You can cancel the event by changing the bool value pointed to by "set" to "false". This function adds an event to Timer's internal queue.
Definition at line 143 of file Timer.cpp. Referenced by SendWindow::reliableSend(), SendWindow::sentPacketTimeoutImpl(), and ~Timer().
|
|
a Template Method, subclasses must override.
Reimplemented in CallbackTimer, and ThreadSpawningTimer. Referenced by timerThreadImpl().
|
|
Get the name of the timer.
Definition at line 61 of file Timer.cpp. Referenced by timerThreadImpl().
|
|
Allows you to set a name for this timer, rpimarily for debugging purposes, since the timer resides in a separate thread, and there are multiple timers, it helps to know which is which.
Definition at line 52 of file Timer.cpp. Referenced by SendWindow::SendWindow(), and ThreadSpawningTimer::instance().
|
|
Thread function.
|
|
This is a thread that waits on the event at the head of the queue, and when the time comes for the event to be fired, it calls doAction() if the event is still valid. This function follows the Template Method design pattern. There is only one template method: "doAction". Definition at line 87 of file Timer.cpp. Referenced by timerThread().
|
|
Prints out the times of all scheduled events.
Reimplemented from BasicObject. |
|
true if we want to destroy this object.
|
|
the event list.
|
|
Used to lock the event list.
|
|
Signalled if there has been a change to the contents of the event list.
|
|
the name of this timer.
|
|
ID of the timer thread.
|