#include <rtt/os/PeriodicThread.hpp>

It has a fixed priority, a name and a (changable) periodicity. The common methods to use are start() and stop().
Step() Overruns are detected and the threshold to 'emergency stop' the thread can be set by setMaxOverrun(). Overruns must be accumulated 'on average' to trigger this behavior: one not overrunning step() compensates for one overrunning step().
Definition at line 65 of file PeriodicThread.hpp.
Public Types | |
| typedef double | Seconds |
| typedef long | secs |
| typedef long | msecs |
| typedef long long | nsecs |
Public Member Functions | |
| PeriodicThread (int priority, const std::string &name, double period, OS::RunnableInterface *r=0) | |
| Create a Thread with a given priority and a name. | |
| PeriodicThread (int scheduler, int priority, const std::string &name, double period, OS::RunnableInterface *r=0) | |
| Create a Thread with a given scheduler type, priority and a name. | |
| 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 of this thread in seconds. | |
| bool | setPeriod (secs s, nsecs ns) |
| Set the periodicity of this thread (seconds, nanoseconds). | |
| void | getPeriod (secs &s, nsecs &ns) const |
| Get the periodicity of this thread (seconds, nanoseconds). | |
| virtual Seconds | getPeriod () const |
| Get the periodicity of this thread in seconds. | |
| virtual nsecs | getPeriodNS () const |
| Get the periodicity of this thread in nano-seconds. | |
| virtual bool | isRunning () const |
| Returns whether the thread is running. | |
| virtual const char * | getName () const |
| Read the name of this task. | |
| virtual RTOS_TASK * | getTask () |
| Get the RTOS_TASK pointer FIXME should this be a const? | |
| 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. | |
| bool | setPeriod (TIME_SPEC p) |
| Set the periodicity of this thread. | |
| virtual bool | setPriority (int priority) |
| Set the priority of this Thread. | |
| virtual int | getPriority () const |
| The priority of this Thread. | |
| virtual void | yield () |
| Yields (but 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. | |
Protected Member Functions | |
| virtual void | continuousStepping (bool yes_no) |
| virtual bool | setToStop () |
| Use this from within step() to stop this thread. | |
| virtual void | step () |
| virtual bool | initialize () |
| virtual void | finalize () |
Protected Attributes | |
| int | threadnb |
| Threads are given an unique number, which follows thread creation order. | |
Friends | |
| void * | periodicThread (void *t) |
| PeriodicThread | ( | int | priority, | |
| const std::string & | name, | |||
| double | period, | |||
| OS::RunnableInterface * | r = 0 | |||
| ) |
Create a Thread with a given priority and a name.
| priority | The priority of the thread, with zero being the highest, 99 being the lowest. | |
| name | The name of the Thread. | |
| period | The period in seconds (eg 0.001) of the thread. | |
| r | The optional RunnableInterface instance to run. If not present, the thread's own virtual functions are executed. |
Definition at line 167 of file PeriodicThread.cpp.
| PeriodicThread | ( | int | scheduler, | |
| int | priority, | |||
| const std::string & | name, | |||
| double | period, | |||
| OS::RunnableInterface * | r = 0 | |||
| ) |
Create a Thread with a given scheduler type, priority and a name.
| scheduler | The scheduler, one of ORO_SCHED_RT or ORO_SCHED_OTHER. | |
| priority | The priority of the thread, with zero being the highest, 99 being the lowest. | |
| name | The name of the Thread. | |
| period | The period in seconds (eg 0.001) of the thread. | |
| r | The optional RunnableInterface instance to run. If not present, the thread's own virtual functions are executed. |
Definition at line 182 of file PeriodicThread.cpp.
| bool run | ( | OS::RunnableInterface * | r | ) | [virtual] |
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 ThreadInterface.
Definition at line 282 of file PeriodicThread.cpp.
References PeriodicThread::isRunning(), and RunnableInterface::setThread().
| bool setScheduler | ( | int | sched_type | ) | [virtual] |
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: |
Implements ThreadInterface.
Definition at line 368 of file PeriodicThread.cpp.
References RTT::OS::CheckScheduler(), and PeriodicThread::getScheduler().
Referenced by SimulationThread::SimulationThread().
| int getScheduler | ( | ) | const [virtual] |
Get the scheduler policy in which this thread runs.
Implements ThreadInterface.
Definition at line 404 of file PeriodicThread.cpp.
Referenced by PeriodicThread::setScheduler().
| bool setPriority | ( | int | priority | ) | [virtual] |
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 ThreadInterface.
Definition at line 482 of file PeriodicThread.cpp.
| int getPriority | ( | ) | const [virtual] |
The priority of this Thread.
Implements ThreadInterface.
Definition at line 487 of file PeriodicThread.cpp.
Referenced by SimulationThread::SimulationThread().
| void terminate | ( | ) |
Exit and destroy the thread.
Definition at line 513 of file PeriodicThread.cpp.
| bool setToStop | ( | ) | [protected, virtual] |
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().
Definition at line 526 of file PeriodicThread.cpp.
| void* periodicThread | ( | void * | t | ) | [friend] |
This is one time initialisation
The real task starts here.
Definition at line 55 of file PeriodicThread.cpp.
int threadnb [protected, inherited] |
Threads are given an unique number, which follows thread creation order.
Definition at line 182 of file ThreadInterface.hpp.
Referenced by ThreadInterface::threadNumber().
1.5.6