Classes | Public Member Functions | Private Types | Private Attributes
coil::Timer Class Reference

Timer class. More...

#include <Timer.h>

Inheritance diagram for coil::Timer:
Inheritance graph
[legend]

List of all members.

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< MutexGuard
typedef coil::Mutex Mutex

Private Attributes

TimeValue m_interval
bool m_running
Mutex m_runningMutex
Mutex m_taskMutex
std::vector< Taskm_tasks

Detailed Description

Timer class.

Invoke the callback function of registered listener periodically at the set cycle.

Since:
0.4.0

Definition at line 53 of file Timer.h.


Member Typedef Documentation

typedef coil::Guard<Mutex> coil::Timer::Guard [private]

Definition at line 57 of file Timer.h.

typedef coil::Mutex coil::Timer::Mutex [private]

Definition at line 56 of file Timer.h.


Constructor & Destructor Documentation

coil::Timer::Timer ( TimeValue interval)

Constructor.

Constructor

Parameters:
intervalThe interval of timer

Definition at line 31 of file Timer.cpp.

coil::Timer::~Timer ( ) [virtual]

Destructor.

Destructor

Definition at line 43 of file Timer.cpp.


Member Function Documentation

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.

Definition at line 120 of file Timer.cpp.

int coil::Timer::open ( void *  args) [virtual]

Create thread for Timer.

Generate thread for Timer.

Create an internal thread for Timer and launch it. This is an override of ACE_Task service class method.

Parameters:
argsUsually 0
Returns:
Creation processing result

Reimplemented from coil::Task.

Definition at line 56 of file Timer.cpp.

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.

Parameters:
listenerListener for the registration
tmThe invocation interval of listener
Returns:
ID of the registerd listener

Definition at line 141 of file Timer.cpp.

ListenerId coil::Timer::registerListenerFunc ( void(*)()  cbf,
TimeValue  tm 
) [inline]

Register listener.

Register listener by specifying the method for callback and the invocation interval.

Parameters:
cbfTarget method for callback
tmThe invocation interval of listener
Returns:
ID of the registerd listener

Definition at line 286 of file Timer.h.

template<class ListenerClass >
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.

Parameters:
objTarget object for callback
cbfTarget method for callback
tmThe invocation interval of listener
Returns:
ID of the registerd listener

Definition at line 255 of file Timer.h.

Start Timer task.

Create a new theread for Timer and start processing.

Definition at line 90 of file Timer.cpp.

Stop Timer tast.

Stop Timer task.

Definition at line 107 of file Timer.cpp.

int coil::Timer::svc ( void  ) [virtual]

Thread execution function for Timer.

Thread execution function for Timer. Invoke the callback function of registered listener.

Returns:
Execution result

Reimplemented from coil::Task.

Definition at line 69 of file Timer.cpp.

Unregister listener.

Unregister the listener specified by ID. If the listener specified by ID is not registerd, false will be returned.

Parameters:
idID of the unregisterd listener
Returns:
Unregistration result

Definition at line 165 of file Timer.cpp.


Member Data Documentation

Definition at line 317 of file Timer.h.

bool coil::Timer::m_running [private]

Definition at line 320 of file Timer.h.

Definition at line 319 of file Timer.h.

Definition at line 334 of file Timer.h.

std::vector<Task> coil::Timer::m_tasks [private]

Definition at line 333 of file Timer.h.


The documentation for this class was generated from the following files:


openrtm_aist
Author(s): Noriaki Ando
autogenerated on Sun Mar 26 2017 03:37:19