This Periodic Thread is meant for executing a PeriodicActivity object periodically. More...
#include <rtt/TimerThread.hpp>
Public Member Functions | |
TimerThread (int priority, const std::string &name, double periodicity) | |
Create a periodic Timer thread. | |
TimerThread (int scheduler, int priority, const std::string &name, double periodicity) | |
Create a periodic Timer thread with a given scheduler type. | |
virtual | ~TimerThread () |
Destructor. | |
bool | addActivity (PeriodicActivity *t) |
Add an Timer that will be ticked every execution period Once added, a timer can not be removed. | |
bool | removeActivity (PeriodicActivity *t) |
virtual bool | run (OS::RunnableInterface *r) |
Run the functionality of one RunnableInterface object. | |
virtual bool | start () |
Start the Thread. | |
virtual bool | stop () |
Stop the Thread. | |
bool | setPeriod (Seconds s) |
Set the periodicity in Seconds. | |
bool | setPeriod (secs s, nsecs ns) |
bool | setPeriod (TIME_SPEC p) |
Set the periodicity of this thread. | |
void | getPeriod (secs &s, nsecs &ns) const |
virtual Seconds | getPeriod () const |
Get the periodicity in Seconds. | |
virtual nsecs | getPeriodNS () const |
Get the periodicity in nanoseconds. | |
virtual bool | isRunning () const |
Returns whether the thread is running. | |
virtual bool | isActive () const |
Returns whether the thread is active. | |
virtual const char * | getName () const |
Read the name of this task. | |
virtual RTOS_TASK * | getTask () |
Get the RTOS_TASK pointer. | |
virtual bool | setScheduler (int sched_type) |
Change the scheduler policy in which this thread runs. | |
virtual int | getScheduler () const |
Get the scheduler policy in which this thread runs. | |
virtual bool | setPriority (int priority) |
Set the priority of this Thread. | |
virtual int | getPriority () const |
The priority of this Thread. | |
virtual void | yield () |
Yields (put to the back of the scheduler queue) the calling thread. | |
void | setMaxOverrun (int m) |
int | getMaxOverrun () const |
void | terminate () |
Exit and destroy the thread. | |
void | emergencyStop () |
unsigned int | threadNumber () const |
The unique thread number (within the same process). | |
Static Public Member Functions | |
static TimerThreadPtr | Instance (int priority, double periodicity) |
Create a TimerThread with a given priority and periodicity, using the default scheduler, ORO_SCHED_RT. | |
static TimerThreadPtr | Instance (int scheduler, int priority, double periodicity) |
Create a TimerThread with a given scheduler, priority and periodicity. | |
Static Public Attributes | |
static const unsigned int | MAX_ACTIVITIES = 64 |
Protected Types | |
typedef std::vector < boost::weak_ptr< TimerThread > > | TimerThreadList |
A Boost weak pointer is used to store non-owning pointers to shared objects. | |
Protected Member Functions | |
virtual bool | initialize () |
virtual void | step () |
virtual void | finalize () |
void | reorderList () |
virtual void | continuousStepping (bool yes_no) |
virtual bool | setToStop () |
Use this from within step() to stop this thread. | |
Protected Attributes | |
OS::MutexRecursive | mutex |
A Activity can not create a activity of same priority from step(). | |
int | threadnb |
Threads are given an unique number, which follows thread creation order. | |
Static Protected Attributes | |
static TimerThreadList | TimerThreads |
All timer threads. |
This Periodic Thread is meant for executing a PeriodicActivity object periodically.
Definition at line 71 of file TimerThread.hpp.
RTT::TimerThread::TimerThread | ( | int | priority, | |
const std::string & | name, | |||
double | periodicity | |||
) |
Create a periodic Timer thread.
priority | The priority of this thread | |
periodicity | The periodicity of this thread in seconds (e.g. 0.001 = 1000Hz ) |
RTT::TimerThread::TimerThread | ( | int | scheduler, | |
int | priority, | |||
const std::string & | name, | |||
double | periodicity | |||
) |
Create a periodic Timer thread with a given scheduler type.
scheduler | The scheduler in which this thread runs | |
priority | The priority of this thread within scheduler | |
periodicity | The periodicity of this thread in seconds (e.g. 0.001 = 1000Hz ) |
virtual Seconds RTT::OS::PeriodicThread::getPeriod | ( | ) | const [virtual, inherited] |
virtual nsecs RTT::OS::PeriodicThread::getPeriodNS | ( | ) | const [virtual, inherited] |
Get the periodicity in nanoseconds.
Return zero if non periodic.
Implements RTT::OS::ThreadInterface.
virtual int RTT::OS::PeriodicThread::getPriority | ( | ) | const [virtual, inherited] |
The priority of this Thread.
Implements RTT::OS::ThreadInterface.
virtual int RTT::OS::PeriodicThread::getScheduler | ( | ) | const [virtual, inherited] |
Get the scheduler policy in which this thread runs.
Implements RTT::OS::ThreadInterface.
virtual RTOS_TASK* RTT::OS::PeriodicThread::getTask | ( | ) | [inline, virtual, inherited] |
Get the RTOS_TASK pointer.
Implements RTT::OS::ThreadInterface.
Definition at line 119 of file PeriodicThread.hpp.
virtual bool RTT::OS::PeriodicThread::isActive | ( | ) | const [virtual, inherited] |
Returns whether the thread is active.
A thread is active between the invocation of start() and the invocation of stop().
Implements RTT::OS::ThreadInterface.
virtual bool RTT::OS::PeriodicThread::isRunning | ( | ) | const [virtual, inherited] |
Returns whether the thread is running.
A thread is running if it is executing its loop() function or in the process of periodically calling step(). Hence for periodic threads, isRunning() == isActive() while for non-periodic threads, isRunning() is only true if isActive() and it is executing loop().
Implements RTT::OS::ThreadInterface.
Reimplemented in RTT::SimulationThread.
virtual bool RTT::OS::PeriodicThread::run | ( | OS::RunnableInterface * | r | ) | [virtual, inherited] |
Run the functionality of one RunnableInterface object.
Only one RunnableInterface object can be run, the old one is disconnected.
r | The object to run or zero to clear. |
Implements RTT::OS::ThreadInterface.
bool RTT::OS::PeriodicThread::setPeriod | ( | Seconds | new_period | ) | [virtual, inherited] |
Set the periodicity in Seconds.
new_period | A positive number expressing the period |
Implements RTT::OS::ThreadInterface.
virtual bool RTT::OS::PeriodicThread::setPriority | ( | int | priority | ) | [virtual, inherited] |
Set the priority of this Thread.
priority | The priority given upon construction of this thread. It has to be interpreted in the current OS scheduler. |
Implements RTT::OS::ThreadInterface.
virtual bool RTT::OS::PeriodicThread::setScheduler | ( | int | sched_type | ) | [virtual, inherited] |
Change the scheduler policy in which this thread runs.
sched_type | An OS-specific value which selects a scheduler. Orocos requires that these two values are available: |
Your OS can in addition provide other sched_type's which map more naturally to the schedulers present. If your OS does not make a distinction between real-time and other, both values may map to the same scheduler type.
Implements RTT::OS::ThreadInterface.
virtual bool RTT::OS::PeriodicThread::setToStop | ( | ) | [protected, virtual, inherited] |
Use this from within step() to stop this thread.
This function will call finalize() as well, thus it is advised to call this function as the last statement in your step().
virtual bool RTT::OS::PeriodicThread::start | ( | ) | [virtual, inherited] |
Start the Thread.
Implements RTT::OS::ThreadInterface.
Reimplemented in RTT::SimulationThread.
virtual bool RTT::OS::PeriodicThread::stop | ( | ) | [virtual, inherited] |
Stop the Thread.
Implements RTT::OS::ThreadInterface.
void RTT::OS::PeriodicThread::terminate | ( | ) | [inherited] |
Exit and destroy the thread.
OS::MutexRecursive RTT::TimerThread::mutex [mutable, protected] |
A Activity can not create a activity of same priority from step().
If so a deadlock will occur.
Definition at line 132 of file TimerThread.hpp.
int RTT::OS::ThreadInterface::threadnb [protected, inherited] |
Threads are given an unique number, which follows thread creation order.
Definition at line 191 of file ThreadInterface.hpp.