MADARA  3.2.3
madara::threads::RCWThread Class Referenceabstract

Abstract base class for implementing RCW threads. More...

#include <RCWThread.h>

Inheritance diagram for madara::threads::RCWThread:
madara::threads::BaseThread

Public Member Functions

virtual ~RCWThread ()
 Destructor. More...
 
virtual void compute (const knowledge::rcw::Transaction &)=0
 Executes the compute porition of a read-compute-write loop. More...
 
virtual void finalize (knowledge::rcw::Transaction &)
 Cleans up any thread residue (usually instances created in setup). More...
 
virtual void setup (knowledge::rcw::Transaction &)
 Setup the thread for later read-compute-write loops. More...
 

Protected Member Functions

virtual void init_control_vars (knowledge::KnowledgeBase &control)
 Initializes the Java thread implementation's control plane variables. More...
 

Protected Attributes

std::string name
 The unique name of your thread. More...
 
madara::knowledge::containers::Integer paused
 thread safe paused flag that may be set by the Threader More...
 
madara::knowledge::containers::Integer terminated
 thread safe terminated flag that may be set by the Threader base More...
 

Private Member Functions

virtual void cleanup (void) overridefinal
 Cleans up any thread residue (usually instances created in init). More...
 
virtual void init (knowledge::KnowledgeBase &kb) overridefinal
 Initializes thread with a MADARA context. More...
 
virtual void run (void) overridefinal
 Executes the main thread logic. More...
 

Private Attributes

std::unique_ptr< knowledge::rcw::Transactiontx_
 

Friends

class Threader
 
class WorkerThread
 Worker threads are MADARA thread entities that manage user-defined threads. More...
 

Detailed Description

Abstract base class for implementing RCW threads.

Users should override setup, compute, and finalize, but should not override the init, run, and cleanup functions from BaseThread

Definition at line 40 of file RCWThread.h.

Constructor & Destructor Documentation

virtual madara::threads::RCWThread::~RCWThread ( )
inlinevirtual

Destructor.

Definition at line 46 of file RCWThread.h.

Member Function Documentation

void RCWThread::cleanup ( void  )
finaloverrideprivatevirtual

Cleans up any thread residue (usually instances created in init).

It's important to note that the only things that would need to be cleaned up are generally ports opened, memory initialized with new/malloc, etc. Anything MADARA related is generally cleaned up for you.

Reimplemented from madara::threads::BaseThread.

Definition at line 20 of file RCWThread.cpp.

virtual void madara::threads::RCWThread::compute ( const knowledge::rcw::Transaction )
pure virtual

Executes the compute porition of a read-compute-write loop.

virtual void madara::threads::RCWThread::finalize ( knowledge::rcw::Transaction )
inlinevirtual

Cleans up any thread residue (usually instances created in setup).

It's important to note that the only things that would need to be cleaned up are generally ports opened, memory initialized with new/malloc, etc. Anything MADARA related is generally cleaned up for you.

Definition at line 76 of file RCWThread.h.

void RCWThread::init ( knowledge::KnowledgeBase kb)
finaloverrideprivatevirtual

Initializes thread with a MADARA context.

Parameters
kbthe knowledge base to interact with

Reimplemented from madara::threads::BaseThread.

Definition at line 7 of file RCWThread.cpp.

virtual void madara::threads::BaseThread::init_control_vars ( knowledge::KnowledgeBase control)
inlineprotectedvirtualinherited

Initializes the Java thread implementation's control plane variables.

Parameters
controlthe control plane between Threader and threads

Reimplemented in madara::threads::JavaThread.

Definition at line 86 of file BaseThread.h.

void RCWThread::run ( void  )
finaloverrideprivatevirtual

Executes the main thread logic.

In a BaseThread, the execute is called once. Afterwards, cleanup is called.

Implements madara::threads::BaseThread.

Definition at line 13 of file RCWThread.cpp.

virtual void madara::threads::RCWThread::setup ( knowledge::rcw::Transaction )
inlinevirtual

Setup the thread for later read-compute-write loops.

Definition at line 60 of file RCWThread.h.

Friends And Related Function Documentation

friend class Threader
friend

Definition at line 55 of file RCWThread.h.

friend class WorkerThread
friend

Worker threads are MADARA thread entities that manage user-defined threads.

Definition at line 54 of file RCWThread.h.

Member Data Documentation

std::string madara::threads::BaseThread::name
protectedinherited

The unique name of your thread.

Definition at line 96 of file BaseThread.h.

madara::knowledge::containers::Integer madara::threads::BaseThread::paused
protectedinherited

thread safe paused flag that may be set by the Threader

Definition at line 107 of file BaseThread.h.

madara::knowledge::containers::Integer madara::threads::BaseThread::terminated
protectedinherited

thread safe terminated flag that may be set by the Threader base

Definition at line 102 of file BaseThread.h.

std::unique_ptr<knowledge::rcw::Transaction> madara::threads::RCWThread::tx_
private

Definition at line 102 of file RCWThread.h.


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