MADARA  3.4.1
madara::threads::BaseThread Class Referenceabstract

Abstract base class for implementing threads. More...

#include <BaseThread.h>

Inheritance diagram for madara::threads::BaseThread:
madara::threads::JavaThread madara::transport::SpliceReadThread madara::transport::UdpTransportReadThread madara::transport::ZMQTransportReadThread madara::transport::MulticastTransportReadThread

Public Member Functions

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

Protected Member Functions

virtual void init_control_vars (knowledge::KnowledgeBase &control)
 Initializes the 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...
 

Friends

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

Detailed Description

Abstract base class for implementing threads.

Definition at line 38 of file BaseThread.h.

Constructor & Destructor Documentation

◆ ~BaseThread()

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

Destructor.

Definition at line 44 of file BaseThread.h.

Member Function Documentation

◆ cleanup()

virtual void madara::threads::BaseThread::cleanup ( void  )
inlinevirtual

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 in madara::transport::UdpTransportReadThread, madara::transport::MulticastTransportReadThread, madara::transport::ZMQTransportReadThread, madara::transport::SpliceReadThread, and madara::threads::JavaThread.

Definition at line 71 of file BaseThread.h.

◆ init()

virtual void madara::threads::BaseThread::init ( knowledge::KnowledgeBase )
inlinevirtual

◆ init_control_vars()

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

Initializes the thread implementation's control plane variables.

Parameters
controlthe control plane between Threader and threads

Reimplemented in madara::threads::JavaThread.

Definition at line 78 of file BaseThread.h.

◆ run()

virtual void madara::threads::BaseThread::run ( void  )
pure virtual

Executes the main thread logic.

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

Implemented in madara::transport::UdpTransportReadThread, madara::transport::ZMQTransportReadThread, madara::transport::SpliceReadThread, and madara::threads::JavaThread.

Friends And Related Function Documentation

◆ Threader

friend class Threader
friend

Definition at line 51 of file BaseThread.h.

◆ WorkerThread

friend class WorkerThread
friend

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

Definition at line 50 of file BaseThread.h.

Member Data Documentation

◆ name

std::string madara::threads::BaseThread::name
protected

The unique name of your thread.

Definition at line 90 of file BaseThread.h.

◆ paused

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

thread safe paused flag that may be set by the Threader

Definition at line 101 of file BaseThread.h.

◆ terminated

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

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

Definition at line 96 of file BaseThread.h.


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