#include <Timer.h>
Classes | |
struct | Task |
Public Member Functions | |
void | invoke () |
Invoke Timer task. | |
virtual int | open (void *args) |
Create thread for Timer. | |
ListenerId | registerListener (ListenerBase *listener, TimeValue tm) |
Register listener. | |
ListenerId | registerListenerFunc (void(*cbf)(), TimeValue tm) |
Register listener. | |
template<class ListenerClass > | |
ListenerId | registerListenerObj (ListenerClass *obj, void(ListenerClass::*cbf)(), TimeValue tm) |
Register listener. | |
void | start () |
Start Timer task. | |
void | stop () |
Stop Timer tast. | |
virtual int | svc (void) |
Thread execution function for Timer. | |
Timer (TimeValue &interval) | |
Constructor. | |
bool | unregisterListener (ListenerId id) |
Unregister listener. | |
virtual | ~Timer () |
Destructor. | |
Private Types | |
typedef coil::Guard< Mutex > | Guard |
typedef coil::Mutex | Mutex |
Private Attributes | |
TimeValue | m_interval |
bool | m_running |
Mutex | m_runningMutex |
Mutex | m_taskMutex |
std::vector< Task > | m_tasks |
Timer class.
Invoke the callback function of registered listener periodically at the set cycle.
typedef coil::Guard<Mutex> coil::Timer::Guard [private] |
typedef coil::Mutex coil::Timer::Mutex [private] |
coil::Timer::Timer | ( | TimeValue & | interval | ) |
coil::Timer::~Timer | ( | ) | [virtual] |
void coil::Timer::invoke | ( | ) |
int coil::Timer::open | ( | void * | args | ) | [virtual] |
ListenerId coil::Timer::registerListener | ( | ListenerBase * | listener, |
TimeValue | tm | ||
) |
Register listener.
Register the listener of callback function invoked from this Timer by specifying the interval. If the same listener has already been regiseterd, the value specified the invocation interval of listener will be updated.
listener | Listener for the registration |
tm | The invocation interval of listener |
ListenerId coil::Timer::registerListenerFunc | ( | void(*)() | cbf, |
TimeValue | tm | ||
) | [inline] |
ListenerId coil::Timer::registerListenerObj | ( | ListenerClass * | obj, |
void(ListenerClass::*)() | cbf, | ||
TimeValue | tm | ||
) | [inline] |
Register listener.
Register listener by specifying the object for callback, the method for callback and the invocation interval.
obj | Target object for callback |
cbf | Target method for callback |
tm | The invocation interval of listener |
void coil::Timer::start | ( | ) |
void coil::Timer::stop | ( | ) |
int coil::Timer::svc | ( | void | ) | [virtual] |
Thread execution function for Timer.
Thread execution function for Timer. Invoke the callback function of registered listener.
Reimplemented from coil::Task.
bool coil::Timer::unregisterListener | ( | ListenerId | id | ) |
TimeValue coil::Timer::m_interval [private] |
bool coil::Timer::m_running [private] |
Mutex coil::Timer::m_runningMutex [private] |
Mutex coil::Timer::m_taskMutex [private] |
std::vector<Task> coil::Timer::m_tasks [private] |