PiImageStreamer
Loading...
Searching...
No Matches
SWE4211RPi::FreeRunningRepeatingTask Class Referenceabstract

A runnable whose taskMethod is invoked back to back, with the rate set by whatever the taskMethod blocks on. More...

#include <FreeRunningRepeatingTask.h>

Inheritance diagram for SWE4211RPi::FreeRunningRepeatingTask:
Collaboration diagram for SWE4211RPi::FreeRunningRepeatingTask:

Public Member Functions

 FreeRunningRepeatingTask (std::string threadName, int priority=1)
 
virtual ~FreeRunningRepeatingTask ()
 
virtual void taskMethod ()=0
 
void run () final
 
virtual void printInformation ()
 
virtual double getCPUUsageInfo ()
 
virtual void resetThreadDiagnostics ()
 
- Public Member Functions inherited from SWE4211RPi::RunnableClass
 RunnableClass (std::string threadName, int priority=0)
 
virtual ~RunnableClass ()
 
virtual pid_t getThreadID ()
 
virtual void start () final
 
virtual void setPriority (int priority) final
 
virtual int getPriority () final
 
virtual bool isShutdown () final
 
virtual bool isStarted () final
 
virtual void stopThreadExecution ()
 
virtual void waitForShutdown ()
 

Protected Member Functions

virtual void startChildRunnables () final
 
virtual void stopChildRunnables () final
 
virtual void startChildTasks ()
 
virtual void stopChildTasks ()
 

Private Member Functions

void invokeRun ()
 

Private Attributes

long worstCaseExecutionTime = 0
 
long lastExecutionTime = 0
 
long missedDeadlineCount = 0
 
long lastWallTime = 0
 
long worstCaseWallTime = 0
 

Additional Inherited Members

- Static Public Member Functions inherited from SWE4211RPi::RunnableClass
static void printThreads ()
 
static void resetAllThreadInformation ()
 
- Protected Attributes inherited from SWE4211RPi::RunnableClass
std::thread * myThread = NULL
 
pthread_t executingThread = 0
 
pid_t myOSThreadID = 0
 
std::string myName
 
std::atomic< bool > keepGoing {true}
 
std::atomic< bool > runCompleted {false}
 
std::atomic< bool > runStarted {false}
 
int priority = -1
 
- Static Protected Attributes inherited from SWE4211RPi::RunnableClass
static std::list< RunnableClass * > runningThreads
 

Detailed Description

A runnable whose taskMethod is invoked back to back, with the rate set by whatever the taskMethod blocks on.

Constructor & Destructor Documentation

◆ FreeRunningRepeatingTask()

FreeRunningRepeatingTask::FreeRunningRepeatingTask ( std::string  threadName,
int  priority = 1 
)

This is the default constructor for the class.

Parameters
threadNameThis is the name of the thread in a human readable format.
priorityThis is the priority for the task.
Here is the call graph for this function:

◆ ~FreeRunningRepeatingTask()

FreeRunningRepeatingTask::~FreeRunningRepeatingTask ( )
virtual

This method will clean up from the periodic task and its execution.

Nothing to be done in the destructor.

Member Function Documentation

◆ getCPUUsageInfo()

double FreeRunningRepeatingTask::getCPUUsageInfo ( )
virtual

This method will obtain the CPU usage. Because there is no fixed period, CPU usage is the worst case measured execution time divided by the worst case wall time.

Returns
The CPU usage will be returned as a percentage.

This method will obtain the CPU usage. Because there is no fixed period, CPU usage is the worst case measured execution time divided by the worst case wall time. The result is not a number (NaN) until the task has run at least once.

Returns
The CPU usage will be returned as a percentage.

Reimplemented from SWE4211RPi::RunnableClass.

Here is the caller graph for this function:

◆ invokeRun()

void SWE4211RPi::FreeRunningRepeatingTask::invokeRun ( )
private

This method is declared but not implemented. RunnableClass::invokeRunMethod() is used instead.

◆ printInformation()

void FreeRunningRepeatingTask::printInformation ( )
virtual

This method will print out information about the given thread. The info will be dependent upon the given thread.

This method will print out information about the given thread. The period column is always 0 because the task has no fixed period.

Reimplemented from SWE4211RPi::RunnableClass.

Here is the call graph for this function:

◆ resetThreadDiagnostics()

void FreeRunningRepeatingTask::resetThreadDiagnostics ( )
virtual

This method will reset thread diagnostics back to their default values. The wall times and CPU times will be set to 0.

This method will reset thread diagnostics back to their default values. The missed deadline count is not reset.

Reimplemented from SWE4211RPi::RunnableClass.

◆ run()

void FreeRunningRepeatingTask::run ( )
finalvirtual

This is the run method for the class. It calls taskMethod() repeatedly until the task is stopped, measuring the CPU and wall time of each invocation and yielding between invocations.

Set keep going to be true, to indicate that the thread is to continue running.

The following gets the wall time at the start of this invocation.

Obtain the cpu time at the start of this invocation. This is for CPU time measurement.

Now run the task. Call the task method.

Now get the end CPU time entry.

Determine where we are in terms of the worst case execution time.

Implements SWE4211RPi::RunnableClass.

Here is the call graph for this function:

◆ startChildRunnables()

void FreeRunningRepeatingTask::startChildRunnables ( )
finalprotectedvirtual

This method will start up any runnable objects which are contained within a class that implements the Runnable interface. It is final for free running tasks and simply calls startChildTasks(). Derived classes override startChildTasks() instead.

This method will start up any runnable objects which are contained within a class that implements the Runnable interface. For a free running task it simply calls startChildTasks().

Reimplemented from SWE4211RPi::RunnableClass.

Here is the call graph for this function:

◆ startChildTasks()

void FreeRunningRepeatingTask::startChildTasks ( )
protectedvirtual

This method will start up any runnable objects which are contained within a class that implements the Runnable interface. If there are no other objects that are runnable, there is no need to override this method. However, if a child class contains an instance of a runnable object, then this method must be overridden in the derived class.

Here is the caller graph for this function:

◆ stopChildRunnables()

void FreeRunningRepeatingTask::stopChildRunnables ( )
finalprotectedvirtual

This method will stop any runnable objects which are contained within a class that implements the Runnable interface. It is final for free running tasks and simply calls stopChildTasks(). Derived classes override stopChildTasks() instead.

This method will stop any runnable objects which are contained within a class that implements the Runnable interface. For a free running task it simply calls stopChildTasks().

Reimplemented from SWE4211RPi::RunnableClass.

Here is the call graph for this function:

◆ stopChildTasks()

void FreeRunningRepeatingTask::stopChildTasks ( )
protectedvirtual

This method will stop any runnable objects which are contained within a class that implements the Runnable interface. If there are no other objects that are runnable, there is no need to override this method. However, if a child class contains an instance of a runnable object, then this method must be overridden in the derived class.

Here is the caller graph for this function:

◆ taskMethod()

virtual void SWE4211RPi::FreeRunningRepeatingTask::taskMethod ( )
pure virtual

This is the task method. The task method will be invoked periodically every taskPeriod units of time, where the period is set by an existing piece of hardware.

Implemented in SWE4211RPi::NewCamera.

Here is the caller graph for this function:

Member Data Documentation

◆ lastExecutionTime

long SWE4211RPi::FreeRunningRepeatingTask::lastExecutionTime = 0
private

This variable holds the last execution value for the CPU, showing the time it took to execute.

◆ lastWallTime

long SWE4211RPi::FreeRunningRepeatingTask::lastWallTime = 0
private

This variable holds the last wall time measurement for the given periodic task. The wall time is the time from the start to the end of the task running.

◆ missedDeadlineCount

long SWE4211RPi::FreeRunningRepeatingTask::missedDeadlineCount = 0
private

This variable will hold the count as to how many times the deadline was missed for the given system. A free running task has no deadline, so this is not currently incremented.

◆ worstCaseExecutionTime

long SWE4211RPi::FreeRunningRepeatingTask::worstCaseExecutionTime = 0
private

This variable stores the worst case execution time from a CPU time standpoint.

◆ worstCaseWallTime

long SWE4211RPi::FreeRunningRepeatingTask::worstCaseWallTime = 0
private

This variable holds the worst case wall time. This is the worst case from start to finish of the given periodic task.


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