PeriodicTask Class Reference

#include <ArmarXCore/core/ArmarXManager.h>

Public Types

typedef void(T::* method_type) (void)
 Typedef for the periodic method. More...
 
using pointer_type = IceUtil::Handle< PeriodicTask< T > >
 Shared pointer type for convenience. More...
 

Public Member Functions

void changeInterval (unsigned int intervalInMs)
 changeInterval changes the interval at which the task is executed. More...
 
IceUtil::Int64 getInterval () const
 
const PeriodicTaskIceBase & getStatistics () const
 
bool isFunctionExecuting () const
 Return the execution state of the thread function. More...
 
bool isRunning () const
 Retrieve running state of the thread. More...
 
 PeriodicTask (T *parent, method_type periodicFn, int periodMs, bool assureMeanInterval=false, std::string name="", bool forceSystemTime=true)
 Constructs a periodic task within the class parent which calls the peridoicFn in a new thread. More...
 
void setDelayWarningTolerance (int newToleranceInMilliSeconds=5)
 
void setName (std::string name)
 Set the name identifying PeriodicTask instances. More...
 
void setThreadList (ThreadListPtr threadList)
 This method sets threadList as PeriodicTask::customThreadList and appends this to the list. More...
 
void start ()
 Starts the thread. More...
 
void stop ()
 Stops the thread. More...
 
 ~PeriodicTask () override
 Destructor stops the thread and waits for completion. More...
 

Detailed Description

The periodic task executes one thread method repeatedly using the time period specified in the constructor.

Definition at line 70 of file ArmarXManager.h.

Member Typedef Documentation

◆ method_type

typedef void(T::* method_type(void)

Typedef for the periodic method.

Thread methods need to follow the template void methodName(void). Parameter passing is not used since methods are members of the class.

Definition at line 62 of file PeriodicTask.h.

◆ pointer_type

Shared pointer type for convenience.

Definition at line 67 of file PeriodicTask.h.

Constructor & Destructor Documentation

◆ PeriodicTask()

PeriodicTask ( T parent,
method_type  periodicFn,
int  periodMs,
bool  assureMeanInterval = false,
std::string  name = "",
bool  forceSystemTime = true 
)
inline

Constructs a periodic task within the class parent which calls the peridoicFn in a new thread.

Parameters
parentthe class wheter periodicFn is member
peridicFnreference to the periodic function implementation
periodMsperiod time in milliseconds
assureMeanIntervalIf set to TRUE, the scheduler tries to compensate timeslot exceedings overtime and not only on the next interval
nameof this thread, that describes what it is doing
forceSystemTimeIf set to false, the Timeserver will be used for timing (if available)

Definition at line 82 of file PeriodicTask.h.

◆ ~PeriodicTask()

~PeriodicTask ( )
inlineoverride

Destructor stops the thread and waits for completion.

Definition at line 130 of file PeriodicTask.h.

Member Function Documentation

◆ changeInterval()

void changeInterval ( unsigned int  intervalInMs)
inline

changeInterval changes the interval at which the task is executed.

The execution starts the first time again after the duration specified in the parameter OR if the task is currently executed after this task

  • the interval specified - cycleDuration.
    Parameters
    intervalInMsnew execution interval in milliseconds.

Definition at line 215 of file PeriodicTask.h.

◆ getInterval()

IceUtil::Int64 getInterval ( ) const
inline
Returns
The scheduling interval of the thread instance in milliseconds

Definition at line 193 of file PeriodicTask.h.

◆ getStatistics()

const PeriodicTaskIceBase& getStatistics ( ) const
inline
Returns
PeriodicTaskIceBase base pointer to the current PeriodicTask instance

Definition at line 275 of file PeriodicTask.h.

◆ isFunctionExecuting()

bool isFunctionExecuting ( ) const
inline

Return the execution state of the thread function.

Returns
PeriodicTask::functionExecuting

Definition at line 266 of file PeriodicTask.h.

◆ isRunning()

bool isRunning ( ) const
inline

Retrieve running state of the thread.

Returns
whether thread is running

Definition at line 256 of file PeriodicTask.h.

◆ setDelayWarningTolerance()

void setDelayWarningTolerance ( int  newToleranceInMilliSeconds = 5)
inline
Returns
Set the tolerance value for delay warnings. If the tasks takes longer than (scheduling interval + tolerance), a warning is issued.
Parameters
newToleranceInMilliSecondsThe tolerance, in milliseconds.

Definition at line 203 of file PeriodicTask.h.

◆ setName()

void setName ( std::string  name)
inline

Set the name identifying PeriodicTask instances.

Parameters
namestring containing the name

Definition at line 148 of file PeriodicTask.h.

◆ setThreadList()

void setThreadList ( ThreadListPtr  threadList)
inline

This method sets threadList as PeriodicTask::customThreadList and appends this to the list.

Parameters
threadLista pointer to the ThreadList instance.

Definition at line 158 of file PeriodicTask.h.

◆ start()

void start ( )
inline

Starts the thread.

Only has effect if the task has not been started. After completion of the task, it can be started again (see isRunning()).

Definition at line 170 of file PeriodicTask.h.

◆ stop()

void stop ( )
inline

Stops the thread.

Only has effect if the task has been started.

Definition at line 235 of file PeriodicTask.h.


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