MADARA  3.4.1
madara::threads::WorkerThread Class Reference

A thread that executes BaseThread logic. More...

#include <WorkerThread.h>

Public Member Functions

 WorkerThread ()
 Default constructor. More...
 
 WorkerThread (const std::string &name, BaseThread *thread, knowledge::KnowledgeBase *control, knowledge::KnowledgeBase *data, double hertz=-1.0)
 Constructor deprecated: use version that takes control and data by value. More...
 
 WorkerThread (const std::string &name, BaseThread *thread, knowledge::KnowledgeBase control, knowledge::KnowledgeBase data, double hertz=-1.0)
 Constructor. More...
 
 WorkerThread (WorkerThread &&other)=default
 
 ~WorkerThread () noexcept
 Destructor. More...
 

Protected Member Functions

void change_frequency (double hertz, utility::TimeValue &current, utility::Duration &frequency, utility::TimeValue &next_epoch, bool &one_shot, bool &blaster)
 Changes the frequency given a hertz rate. More...
 
void run (void)
 Starts the thread, with entry point svc() More...
 
int svc (void)
 Task loop. More...
 

Protected Attributes

knowledge::KnowledgeBase control_
 the control plane to the knowledge base More...
 
knowledge::KnowledgeBase data_
 the data plane (the knowledge base) More...
 
knowledge::containers::Integer debug_
 flag for whether or not to save debug information in control More...
 
knowledge::containers::Integer end_time_
 timestamp of the last svc end More...
 
knowledge::containers::Integer executions_
 thread safe start flag that will be sent to the knowledge base on launch of the thread More...
 
knowledge::containers::Integer finished_
 thread safe finished flag that will be sent to the knowledge base on completion of the thread More...
 
double hertz_ = -1
 hertz rate for worker thread executions More...
 
knowledge::containers::Integer last_duration_
 duration of last run More...
 
knowledge::containers::Integer last_start_time_
 timestamp of the last svc start More...
 
knowledge::containers::Integer max_duration_
 maximum duration of all runs More...
 
std::thread me_
 Assignment operator. More...
 
knowledge::containers::Integer min_duration_
 minimum duration of all runs More...
 
std::string name_
 the name of the contained thread More...
 
knowledge::containers::Double new_hertz_
 thread safe hertz reference More...
 
madara::knowledge::containers::Integer paused_
 thread safe paused flag that will be sent to the knowledge base to indicate thread activities should pause More...
 
madara::knowledge::containers::Integer running_
 thread safe paused flag that will be sent to the knowledge base to indicate thread activities should pause More...
 
knowledge::containers::Integer start_time_
 timestamp of the initial svc start More...
 
knowledge::containers::Integer started_
 thread safe start flag that will be sent to the knowledge base on launch of the thread More...
 
std::unique_ptr< BaseThreadthread_ = nullptr
 the contained thread More...
 

Friends

class Threader
 give access to our status flags to the Threader class More...
 

Detailed Description

A thread that executes BaseThread logic.

Users should

Definition at line 32 of file WorkerThread.h.

Constructor & Destructor Documentation

◆ WorkerThread() [1/4]

madara::threads::WorkerThread::WorkerThread ( )
inline

Default constructor.

Definition at line 41 of file WorkerThread.h.

◆ WorkerThread() [2/4]

madara::threads::WorkerThread::WorkerThread ( const std::string &  name,
BaseThread thread,
knowledge::KnowledgeBase control,
knowledge::KnowledgeBase data,
double  hertz = -1.0 
)
inline

Constructor deprecated: use version that takes control and data by value.

Parameters
namethe name of the user thread
threadthe user thread
controlthe knowledge base that provides a control plane between the data knowledge base and threads
datathe knowledge base that provides user data access
hertzthe hertz rate to run the thread

Definition at line 54 of file WorkerThread.h.

◆ WorkerThread() [3/4]

madara::threads::WorkerThread::WorkerThread ( const std::string &  name,
BaseThread thread,
knowledge::KnowledgeBase  control,
knowledge::KnowledgeBase  data,
double  hertz = -1.0 
)

Constructor.

Parameters
namethe name of the user thread
threadthe user thread
controlthe knowledge base that provides a control plane between the data knowledge base and threads
datathe knowledge base that provides user data access
hertzthe hertz rate to run the thread

Definition at line 22 of file WorkerThread.cpp.

◆ WorkerThread() [4/4]

madara::threads::WorkerThread::WorkerThread ( WorkerThread &&  other)
default

◆ ~WorkerThread()

madara::threads::WorkerThread::~WorkerThread ( )
noexcept

Destructor.

Definition at line 71 of file WorkerThread.cpp.

Member Function Documentation

◆ change_frequency()

void madara::threads::WorkerThread::change_frequency ( double  hertz,
utility::TimeValue current,
utility::Duration frequency,
utility::TimeValue next_epoch,
bool &  one_shot,
bool &  blaster 
)
inlineprotected

Changes the frequency given a hertz rate.

Parameters
hertzthe new hertz rate
currentcurrent time
frequencyan updated frequency value
next_epochnext time to trigger execution
one_shotif hertz rate is less than 0, true. Otherwise, false
blasterif hertz rate is 0, true. Otherwise, false.

Definition at line 17 of file WorkerThread.inl.

◆ run()

void madara::threads::WorkerThread::run ( void  )
protected

Starts the thread, with entry point svc()

Definition at line 123 of file WorkerThread.cpp.

◆ svc()

int madara::threads::WorkerThread::svc ( void  )
protected

Task loop.

Definition at line 152 of file WorkerThread.cpp.

Friends And Related Function Documentation

◆ Threader

friend class Threader
friend

give access to our status flags to the Threader class

Definition at line 36 of file WorkerThread.h.

Member Data Documentation

◆ control_

knowledge::KnowledgeBase madara::threads::WorkerThread::control_
protected

the control plane to the knowledge base

Definition at line 121 of file WorkerThread.h.

◆ data_

knowledge::KnowledgeBase madara::threads::WorkerThread::data_
protected

the data plane (the knowledge base)

Definition at line 124 of file WorkerThread.h.

◆ debug_

knowledge::containers::Integer madara::threads::WorkerThread::debug_
protected

flag for whether or not to save debug information in control

Definition at line 194 of file WorkerThread.h.

◆ end_time_

knowledge::containers::Integer madara::threads::WorkerThread::end_time_
protected

timestamp of the last svc end

Definition at line 174 of file WorkerThread.h.

◆ executions_

knowledge::containers::Integer madara::threads::WorkerThread::executions_
protected

thread safe start flag that will be sent to the knowledge base on launch of the thread

Definition at line 159 of file WorkerThread.h.

◆ finished_

knowledge::containers::Integer madara::threads::WorkerThread::finished_
protected

thread safe finished flag that will be sent to the knowledge base on completion of the thread

Definition at line 130 of file WorkerThread.h.

◆ hertz_

double madara::threads::WorkerThread::hertz_ = -1
protected

hertz rate for worker thread executions

Definition at line 199 of file WorkerThread.h.

◆ last_duration_

knowledge::containers::Integer madara::threads::WorkerThread::last_duration_
protected

duration of last run

Definition at line 179 of file WorkerThread.h.

◆ last_start_time_

knowledge::containers::Integer madara::threads::WorkerThread::last_start_time_
protected

timestamp of the last svc start

Definition at line 169 of file WorkerThread.h.

◆ max_duration_

knowledge::containers::Integer madara::threads::WorkerThread::max_duration_
protected

maximum duration of all runs

Definition at line 189 of file WorkerThread.h.

◆ me_

std::thread madara::threads::WorkerThread::me_
protected

Assignment operator.

Parameters
inputthread information to copy

Definition at line 88 of file WorkerThread.h.

◆ min_duration_

knowledge::containers::Integer madara::threads::WorkerThread::min_duration_
protected

minimum duration of all runs

Definition at line 184 of file WorkerThread.h.

◆ name_

std::string madara::threads::WorkerThread::name_
protected

the name of the contained thread

Definition at line 115 of file WorkerThread.h.

◆ new_hertz_

knowledge::containers::Double madara::threads::WorkerThread::new_hertz_
protected

thread safe hertz reference

Definition at line 153 of file WorkerThread.h.

◆ paused_

madara::knowledge::containers::Integer madara::threads::WorkerThread::paused_
protected

thread safe paused flag that will be sent to the knowledge base to indicate thread activities should pause

Definition at line 136 of file WorkerThread.h.

◆ running_

madara::knowledge::containers::Integer madara::threads::WorkerThread::running_
protected

thread safe paused flag that will be sent to the knowledge base to indicate thread activities should pause

Definition at line 142 of file WorkerThread.h.

◆ start_time_

knowledge::containers::Integer madara::threads::WorkerThread::start_time_
protected

timestamp of the initial svc start

Definition at line 164 of file WorkerThread.h.

◆ started_

knowledge::containers::Integer madara::threads::WorkerThread::started_
protected

thread safe start flag that will be sent to the knowledge base on launch of the thread

Definition at line 148 of file WorkerThread.h.

◆ thread_

std::unique_ptr<BaseThread> madara::threads::WorkerThread::thread_ = nullptr
protected

the contained thread

Definition at line 118 of file WorkerThread.h.


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