|
discoLight
|
#include <RunnableClass.h>

Public Member Functions | |
| RunnableClass (std::string threadName, int priority=0) | |
| virtual | ~RunnableClass () |
| virtual void | resetThreadDiagnostics () |
| virtual void | printInformation () |
| virtual double | getCPUUsageInfo () |
| virtual pid_t | getThreadID () |
| virtual void | start () final |
| virtual void | setPriority (int priority) final |
| virtual int | getPriority () final |
| virtual void | run ()=0 |
| virtual bool | isShutdown () final |
| virtual bool | isStarted () final |
| virtual void | stopThreadExecution () |
| virtual void | waitForShutdown () |
Static Public Member Functions | |
| static void | printThreads () |
| static void | resetAllThreadInformation () |
Protected Member Functions | |
| virtual void | startChildRunnables () |
| virtual void | stopChildRunnables () |
Protected Attributes | |
| std::thread * | myThread = NULL |
| pthread_t | executingThread = 0 |
| pid_t | myOSThreadID = 0 |
| std::string | myName |
| bool | keepGoing = true |
| bool | runCompleted = false |
| bool | runStarted = false |
| int | priority = -1 |
Static Protected Attributes | |
| static std::list< RunnableClass * > | runningThreads |
Private Member Functions | |
| virtual void | invokeRunMethod () final |
This is the runnable class, which mimics the runnable interface from Java. It is a virtual class which should not directly be instantiated.
| RunnableClass::RunnableClass | ( | std::string | threadName, |
| int | priority = 0 |
||
| ) |
This is the default constructor for the class.
| threadName | This is the name of the thread in a human readable format. |
| priority | This is the priority for the task. By default, will be 0 unless another priority is passed into the constructor. |
This is the default constructor for the class.
| threadName | This is the name of the thread in a human readable format. |
|
virtual |
This is the default destructor for the class. It must properly clean up the instantiated thread.
If the thread is not NULL, delete it.
|
virtual |
This method will return the CPU usage for the given task. The usage will be as a percentage value.
Note that for a simple runnable class, we do not currently have this metric.
Reimplemented in SWE4211RPi::FreeRunningRepeatingTask, and SWE4211RPi::PeriodicTask.

|
finalvirtual |
This method will obtain the priority set for this runnable class.

|
virtual |
This method will obtain the thread ID for this runnable.
|
finalprivatevirtual |
This private method initializes the runnable class. It is actually the method invoked when the thread starts, and it will ultimately call the Run method.
This private method initializes the runnable class. It is actually the method invoked when the thread starts.


|
finalvirtual |
This method will determine if the given thread is shutdown.
|
finalvirtual |
This method will determine if the given runnable class has been started or not.
|
virtual |
This method will print out information about the given thread. The info will be dependent upon the given thread.
Reimplemented in SWE4211RPi::FreeRunningRepeatingTask, and SWE4211RPi::PeriodicTask.


|
static |
This method will print out to the console each of the running threads and their thread ID's.

|
static |
This method will reset the thread information which is dynamic in nature and changes as the robot runs. This predominantly impacts threads which are not part of the Runnable class.

|
virtual |
This method will reset thread diagnostics back to their default values.
Reimplemented in SWE4211RPi::FreeRunningRepeatingTask, and SWE4211RPi::PeriodicTask.

|
pure virtual |
This is the virtual run method. It will execute the given code that is to be executed by this class.
Implemented in SWE4211RPi::NetworkManager, SWE4211RPi::FreeRunningRepeatingTask, SWE4211RPi::GenericThreadInfo, and SWE4211RPi::PeriodicTask.

|
finalvirtual |
This method will set the priority for the given task, using the real time FIFO scheduler as well as setting the priority.
| priority | This is the priority for the task. It must be between 0 and 99, with 99 being the highest priority. |
This method will set the priority for the given task.
| priority | This is the priority for the task. It must be between 0 and 99, with 99 being the highest priority. |

|
finalvirtual |
This virtual method is the start method. It must be implemented in child classes. The purpose of this method is to instantiate a new thread and invoke the run method. This method will cause the task to start with the default priority.

|
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.
This default implementation does nothing.
Reimplemented in SWE4211RPi::FreeRunningRepeatingTask, and SWE4211RPi::PeriodicTask.

|
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.
This default implementation does nothing.
Reimplemented in SWE4211RPi::FreeRunningRepeatingTask, and SWE4211RPi::PeriodicTask.

|
virtual |
This method will stop the execution of the given class.
Stop the thread by changing the value of keepGoing if the thread is running. If there is a child class that has a RUnnable object inside of it, then stop must be called on that object.
Reimplemented in SWE4211RPi::PulsedGPIOPin, and SWE4211RPi::NetworkManager.


|
virtual |
This method will block waiting for the given thread to terminate before continuing. This should be overridden if any child class has it's own runnable objects encapsulated within it.
This method will block waiting for the given thread to terminate before continuing. If a class that is derived from this class has a child class with a RUnnable object, this method must be overridden to wait for the child method to shutdown.
If thread is joinable
Join the thread and wait for shutdown.
|
protected |
This attribute is the executing thread. It is set when the thread is started and then is cached afterwards.
|
protected |
This variable will determine whether or not the given thread is to continue executing. If this goes to false, then the thread is to shutdown in an appropriate manner.
|
protected |
This is the name of the thread. It is shown as a string so that it can easily be viewed in human-readable format.
|
protected |
This is the thread id (tid) for this task.
|
protected |
This is the instance of the thread that is to be executed by this class. At instantiation it is NULL. It will be instantiated when the start method of the class is invoked.
|
protected |
This is the priority of the given thread. A value of -1 indicates no change in the priority and to use the default setup. For a runnable class, this must be set before the class starts. For other derived classes, it may be changeable at run time.
|
protected |
This variable will determine if the current Runnable class has completed execution and the run method has returned.
|
staticprotected |
This is a list of all of the running threads which have been started by this set of libraries.
|
protected |
This variable will determine whether or not the current task has been started or not.