OpenRTM-aist
1.2.1
|
#include <Timer.h>
Public Member Functions | |
Timer (TimeValue &interval) | |
Constructor. More... | |
virtual | ~Timer () |
Destructor. More... | |
virtual int | open (void *args) |
Create thread for Timer. More... | |
virtual int | svc (void) |
Thread execution function for Timer. More... | |
void | start () |
Start Timer task. More... | |
void | stop () |
Stop Timer task. More... | |
void | invoke () |
Invoke Timer task. More... | |
ListenerId | registerListener (ListenerBase *listener, TimeValue tm) |
Register listener. More... | |
template<class ListenerClass > | |
ListenerId | registerListenerObj (ListenerClass *obj, void(ListenerClass::*cbf)(), TimeValue tm) |
Register listener. More... | |
ListenerId | registerListenerFunc (void(*cbf)(), TimeValue tm) |
Register listener. More... | |
bool | unregisterListener (ListenerId id) |
Unregister listener. More... | |
Public Member Functions inherited from coil::Task | |
Task () | |
Constructor. More... | |
virtual | ~Task () |
Destructor. More... | |
virtual int | close (unsigned long flags=0) |
Task close. More... | |
virtual void | activate () |
Create a thread. More... | |
virtual int | wait (void) |
Waiting for the thread terminate. More... | |
virtual int | suspend (void) |
Suspending the task. More... | |
virtual int | resume (void) |
Resuming the suspended task. More... | |
virtual void | reset () |
Reset of task count. More... | |
virtual void | finalize () |
Finalizing the task. More... | |
Additional Inherited Members | |
Static Public Member Functions inherited from coil::Task | |
static void * | svc_run (void *args=0) |
Start thread Execution. More... | |
Timer class.
Invoke the callback function of registered listener periodically at the set cycle.
coil::Timer::Timer | ( | TimeValue & | interval | ) |
Constructor.
Constructor
interval | The interval of timer |
|
virtual |
Destructor.
Destructor
void coil::Timer::invoke | ( | ) |
Invoke Timer task.
Subtract the interval of timer from the waiting time for invocation of each registered listener. If the listener whose waiting time reached 0 exists, invoke the callback function.
|
virtual |
Create thread for Timer.
Create an internal thread for Timer and launch it. This is an override of ACE_Task service class method.
args | Usually 0 |
Reimplemented from coil::Task.
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 |
Referenced by registerListenerFunc(), and registerListenerObj().
|
inline |
Register listener.
Register listener by specifying the method for callback and the invocation interval.
cbf | Target method for callback |
tm | The invocation interval of listener |
References registerListener(), coil::Task::Task(), and unregisterListener().
|
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 |
References registerListener().
|
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 | ) |
Unregister listener.
Unregister the listener specified by ID. If the listener specified by ID is not registerd, false will be returned.
id | ID of the unregisterd listener |
Referenced by registerListenerFunc().