PeriodicTask< T > Class Template Reference

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

#include <ArmarXCore/core/services/tasks/PeriodicTask.h>

+ Inheritance diagram for PeriodicTask< T >:

Public Types

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

Public Member Functions

void changeInterval (unsigned int intervalInMs)
 changeInterval changes the interval at which the task is executed.
 
IceUtil::Int64 getInterval () const
 
const PeriodicTaskIceBase & getStatistics () const
 
bool isFunctionExecuting () const
 Return the execution state of the thread function.
 
bool isRunning () const
 Retrieve running state of the thread.
 
 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.
 
void setDelayWarningTolerance (int newToleranceInMilliSeconds=5)
 
void setName (std::string name)
 Set the name identifying PeriodicTask instances.
 
void setThreadList (ThreadListPtr threadList)
 This method sets threadList as PeriodicTask::customThreadList and appends this to the list.
 
void start ()
 Starts the thread.
 
void stop ()
 Stops the thread.
 
 ~PeriodicTask () override
 Destructor stops the thread and waits for completion.
 
- Public Member Functions inherited from Logging
SpamFilterDataPtr deactivateSpam (float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const
 disables the logging for the current line for the given amount of seconds.
 
MessageTypeT getEffectiveLoggingLevel () const
 
 Logging ()
 
void setLocalMinimumLoggingLevel (MessageTypeT level)
 With setLocalMinimumLoggingLevel the minimum verbosity-level of log-messages can be set.
 
void setTag (const LogTag &tag)
 
void setTag (const std::string &tagName)
 
virtual ~Logging ()
 

Additional Inherited Members

- Protected Member Functions inherited from Logging
bool checkLogLevel (MessageTypeT level) const
 
const LogSenderPtr & getLogSender () const
 Retrieve log sender.
 
LogSenderPtr loghelper (const char *file, int line, const char *function) const
 
- Protected Attributes inherited from Logging
MessageTypeT minimumLoggingLevel
 
SpamFilterDataPtr spamFilter
 
LogTag tag
 

Detailed Description

template<class T>
class armarx::PeriodicTask< T >

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

Member Typedef Documentation

◆ method_type

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

◆ pointer_type

template<class T>
using pointer_type = IceUtil::Handle<PeriodicTask<T>>

Shared pointer type for convenience.

Constructor & Destructor Documentation

◆ PeriodicTask()

template<class T>
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)

◆ ~PeriodicTask()

template<class T>
~PeriodicTask ( )
inlineoverride

Destructor stops the thread and waits for completion.

Member Function Documentation

◆ changeInterval()

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

◆ getInterval()

template<class T>
IceUtil::Int64 getInterval ( ) const
inline
Returns
The scheduling interval of the thread instance in milliseconds

◆ getStatistics()

template<class T>
const PeriodicTaskIceBase & getStatistics ( ) const
inline
Returns
PeriodicTaskIceBase base pointer to the current PeriodicTask instance

◆ isFunctionExecuting()

template<class T>
bool isFunctionExecuting ( ) const
inline

Return the execution state of the thread function.

Returns
PeriodicTask::functionExecuting

◆ isRunning()

template<class T>
bool isRunning ( ) const
inline

Retrieve running state of the thread.

Returns
whether thread is running

◆ setDelayWarningTolerance()

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

◆ setName()

template<class T>
void setName ( std::string name)
inline

Set the name identifying PeriodicTask instances.

Parameters
namestring containing the name

◆ setThreadList()

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

◆ start()

template<class T>
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()).

◆ stop()

template<class T>
void stop ( )
inline

Stops the thread.

Only has effect if the task has been started.


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