MADARA  3.2.3
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 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...
 
std::thread me_
 Assignment operator. More...
 
std::string name_
 the name of the contained thread More...
 
knowledge::containers::Double new_hertz_
 thread safe hertz reference 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 33 of file WorkerThread.h.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 42 of file WorkerThread.h.

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 55 of file WorkerThread.h.

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 17 of file WorkerThread.cpp.

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

Destructor.

Definition at line 47 of file WorkerThread.cpp.

Member Function Documentation

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 16 of file WorkerThread.inl.

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

Starts the thread, with entry point svc()

Definition at line 82 of file WorkerThread.cpp.

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

Task loop.

Definition at line 110 of file WorkerThread.cpp.

Friends And Related Function Documentation

friend class Threader
friend

give access to our status flags to the Threader class

Definition at line 37 of file WorkerThread.h.

Member Data Documentation

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

the control plane to the knowledge base

Definition at line 128 of file WorkerThread.h.

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

the data plane (the knowledge base)

Definition at line 131 of file WorkerThread.h.

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 137 of file WorkerThread.h.

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

hertz rate for worker thread executions

Definition at line 153 of file WorkerThread.h.

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

Assignment operator.

Parameters
inputthread information to copy

Definition at line 94 of file WorkerThread.h.

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

the name of the contained thread

Definition at line 122 of file WorkerThread.h.

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

thread safe hertz reference

Definition at line 148 of file WorkerThread.h.

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 143 of file WorkerThread.h.

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

the contained thread

Definition at line 125 of file WorkerThread.h.


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