Classes | Public Member Functions | Private Types | Private Attributes | List of all members
coil::Timer Class Reference

Timer class. More...

#include <Timer.h>

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

Classes

struct  Task
 

Public Member Functions

void invoke ()
 Invoke Timer task. More...
 
virtual int open (void *args)
 Create thread for Timer. More...
 
ListenerId registerListener (ListenerBase *listener, TimeValue tm)
 Register listener. More...
 
ListenerId registerListenerFunc (void(*cbf)(), TimeValue tm)
 Register listener. More...
 
template<class ListenerClass >
ListenerId registerListenerObj (ListenerClass *obj, void(ListenerClass::*cbf)(), TimeValue tm)
 Register listener. More...
 
void start ()
 Start Timer task. More...
 
void stop ()
 Stop Timer task. More...
 
virtual int svc (void)
 Thread execution function for Timer. More...
 
 Timer (TimeValue &interval)
 Constructor. More...
 
bool unregisterListener (ListenerId id)
 Unregister listener. More...
 
virtual ~Timer ()
 Destructor. More...
 
- Public Member Functions inherited from coil::Task
virtual void activate ()
 Create a thread. More...
 
virtual void activate ()
 Create a thread. More...
 
virtual int close (unsigned long flags=0)
 Task close. More...
 
virtual int close (unsigned long flags=0)
 Task close. More...
 
virtual void finalize ()
 Finalizing the task. More...
 
virtual void finalize ()
 Finalizing the task. More...
 
virtual void reset ()
 Reset of task count. More...
 
virtual void reset ()
 Reset of task count. More...
 
virtual int resume (void)
 Resuming the suspended task. More...
 
virtual int resume (void)
 Resuming the suspended task. More...
 
virtual int suspend (void)
 Suspending the task. More...
 
virtual int suspend (void)
 Suspending the task. More...
 
 Task ()
 Constructor. More...
 
 Task ()
 Constructor. More...
 
virtual int wait (void)
 Waiting for the thread terminate. More...
 
virtual int wait (void)
 Waiting for the thread terminate. More...
 
virtual ~Task ()
 Destructor. More...
 
virtual ~Task ()
 Destructor. More...
 

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
 

Additional Inherited Members

- Static Public Member Functions inherited from coil::Task
static void * svc_run (void *args=0)
 Start thread Execution. More...
 
static unsigned int WINAPI svc_run (void *args=0)
 Start thread Execution. More...
 

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

◆ Guard

Definition at line 57 of file Timer.h.

◆ Mutex

Definition at line 56 of file Timer.h.

Constructor & Destructor Documentation

◆ Timer()

coil::Timer::Timer ( TimeValue interval)

Constructor.

Constructor

Parameters
intervalThe interval of timer

Definition at line 31 of file Timer.cpp.

◆ ~Timer()

coil::Timer::~Timer ( )
virtual

Destructor.

Destructor

Definition at line 43 of file Timer.cpp.

Member Function Documentation

◆ invoke()

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.

Definition at line 120 of file Timer.cpp.

◆ open()

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.

◆ registerListener()

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.

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

Definition at line 141 of file Timer.cpp.

◆ registerListenerFunc()

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.

◆ registerListenerObj()

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()

void coil::Timer::start ( )

Start Timer task.

Create a new theread for Timer and start processing.

Definition at line 90 of file Timer.cpp.

◆ stop()

void coil::Timer::stop ( )

Stop Timer task.

Stop Timer tast.

Stop Timer task.

Definition at line 107 of file Timer.cpp.

◆ svc()

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.

◆ unregisterListener()

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.

Parameters
idID of the unregisterd listener
Returns
Unregistration result

Definition at line 165 of file Timer.cpp.

Member Data Documentation

◆ m_interval

TimeValue coil::Timer::m_interval
private

Definition at line 317 of file Timer.h.

◆ m_running

bool coil::Timer::m_running
private

Definition at line 320 of file Timer.h.

◆ m_runningMutex

Mutex coil::Timer::m_runningMutex
private

Definition at line 319 of file Timer.h.

◆ m_taskMutex

Mutex coil::Timer::m_taskMutex
private

Definition at line 334 of file Timer.h.

◆ m_tasks

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 Mon Feb 28 2022 23:00:46