SoDaRadio-5.0.3-master:8901fb5
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SoDa::SoDaThread Class Referenceabstract

The Thread baseclass for all SoDa thread objects. More...

#include <SoDaBase.hxx>

Inheritance diagram for SoDa::SoDaThread:
SoDa::SoDaBase SoDa::Debug SoDa::BaseBandRX SoDa::BaseBandTX SoDa::CWTX SoDa::GPSmon SoDa::TestServer SoDa::UI SoDa::USRPCtrl SoDa::USRPRX SoDa::USRPTX SoDaTest::MultiMBox_Test_Thread SoDaTest::ThN

Public Member Functions

 SoDaThread (const std::string &oname)
 
void start ()
 Execute the threads run loop. More...
 
void join ()
 more properly "Wait for this thread to exit its run loop". More...
 
bool waitForJoin (unsigned int m)
 wait for the thread to stop running, or the specified time to pass. More...
 
virtual void run ()=0
 Each thread object must define its "run" loop. More...
 
void execCommand (Command *cmd)
 Execute (dispatch) a message removed from the command stream to one of the basic Command handler functions. More...
 
virtual void execGetCommand (Command *cmd)
 optional method to handle "GET" commands – commands that request a response More...
 
virtual void execSetCommand (Command *cmd)
 optional method to handle "SET" commands – commands that set internal state in the object. More...
 
virtual void execRepCommand (Command *cmd)
 optional method that reports status or the result of some action. More...
 
- Public Member Functions inherited from SoDa::SoDaBase
 SoDaBase (const std::string &oname)
 The constructor – pass a name for the object. More...
 
std::string & getObjName ()
 get the name of this object More...
 
SoDaBasefindSoDaObject (const std::string &oname)
 find a SoDa Object by name. More...
 
double getTime ()
 Get a time stamp in nS resolution that monotonically increases and that is very inexpensive (typically < 100nS). More...
 
- Public Member Functions inherited from SoDa::Debug
 Debug (std::string _unit_name=std::string("UNKNOWN"))
 
 Debug (const char *_unit_name_cstr)
 
 Debug (unsigned int _debug_level, std::string _unit_name=std::string("UNKNOWN"))
 
 Debug (unsigned int _debug_level, const char *_unit_name_cstr)
 
void debugMsg (const std::string &msg, unsigned int threshold=1)
 
void debugMsg (const boost::format &fmt, unsigned int threshold=1)
 
void debugMsg (const char *msg, unsigned int threshold=1)
 
void setDebugLevel (unsigned int v)
 
unsigned int getDebugLevel ()
 

Private Member Functions

void outerRun ()
 the run method that is called by the boost thread handler. More...
 
void hookSigSeg ()
 

Static Private Member Functions

static void sigsegHandler (int sig)
 

Private Attributes

boost::thread * th
 

Additional Inherited Members

- Static Public Member Functions inherited from SoDa::Debug
static void setDefaultLevel (unsigned int v)
 
static unsigned int getDefaultLevel ()
 
static void setGlobalLevel (unsigned int v)
 
static unsigned int getGlobalLevel ()
 
- Static Public Attributes inherited from SoDa::Debug
static boost::mutex debug_msg_mutex
 
- Protected Member Functions inherited from SoDa::Debug
std::string curDateTime ()
 
- Protected Attributes inherited from SoDa::Debug
std::string unit_name
 the name of the unit reporting status More...
 
unsigned int debug_level
 the debug level (threshold) for messages More...
 
- Static Protected Attributes inherited from SoDa::Debug
static unsigned int default_debug_level = 0
 
static unsigned int global_debug_level = 0
 

Detailed Description

The Thread baseclass for all SoDa thread objects.

The SoDaThread baseclass simplifies interaction with threads. Since SoDa thread objects aren't created and destroyed very often, we don't need many bells and whistles here. Just the ability to start a thread a join a thread.

All threads, however, must declare a "run" function, and handlers for three types of SoDa::Command objects (GET, SET, and REPort)

Definition at line 284 of file SoDaBase.hxx.

Constructor & Destructor Documentation

◆ SoDaThread()

SoDa::SoDaThread::SoDaThread ( const std::string &  oname)
inline

Definition at line 286 of file SoDaBase.hxx.

Member Function Documentation

◆ execCommand()

void SoDa::SoDaThread::execCommand ( Command cmd)
inline

Execute (dispatch) a message removed from the command stream to one of the basic Command handler functions.

This sequence appears in so many of the instances of SoDaThread that it was factored out.

Parameters
cmdthe command message to be handled

Definition at line 335 of file SoDaBase.hxx.

References SoDa::Command::cmd, SoDa::Command::GET, SoDa::Command::REP, and SoDa::Command::SET.

Referenced by SoDa::UI::run(), SoDa::GPSmon::run(), SoDa::CWTX::run(), SoDa::USRPTX::run(), SoDa::BaseBandTX::run(), and SoDa::BaseBandRX::run().

◆ execGetCommand()

virtual void SoDa::SoDaThread::execGetCommand ( Command cmd)
inlinevirtual

optional method to handle "GET" commands – commands that request a response

Reimplemented in SoDa::USRPCtrl, SoDa::BaseBandRX, SoDa::UI, SoDa::USRPTX, SoDa::BaseBandTX, SoDa::USRPRX, SoDa::CWTX, and SoDa::GPSmon.

Definition at line 355 of file SoDaBase.hxx.

◆ execRepCommand()

virtual void SoDa::SoDaThread::execRepCommand ( Command cmd)
inlinevirtual

optional method that reports status or the result of some action.

Reimplemented in SoDa::USRPCtrl, SoDa::BaseBandRX, SoDa::USRPTX, SoDa::UI, SoDa::BaseBandTX, SoDa::CWTX, SoDa::USRPRX, and SoDa::GPSmon.

Definition at line 365 of file SoDaBase.hxx.

◆ execSetCommand()

virtual void SoDa::SoDaThread::execSetCommand ( Command cmd)
inlinevirtual

optional method to handle "SET" commands – commands that set internal state in the object.

Reimplemented in SoDa::USRPCtrl, SoDa::BaseBandRX, SoDa::USRPTX, SoDa::UI, SoDa::BaseBandTX, SoDa::CWTX, SoDa::USRPRX, and SoDa::GPSmon.

Definition at line 360 of file SoDaBase.hxx.

◆ hookSigSeg()

void SoDa::SoDaThread::hookSigSeg ( )
inlineprivate

Definition at line 416 of file SoDaBase.hxx.

References sigsegHandler().

◆ join()

void SoDa::SoDaThread::join ( )
inline

more properly "Wait for this thread to exit its run loop".

returns after the thread has received a STOP message.

Definition at line 301 of file SoDaBase.hxx.

Referenced by doWork().

◆ outerRun()

void SoDa::SoDaThread::outerRun ( )
inlineprivate

the run method that is called by the boost thread handler.

This method wraps the thread objects run loop in an exception handler so that we can do something useful with it.

Definition at line 376 of file SoDaBase.hxx.

References SoDa::SoDaException::toString().

Referenced by start().

◆ run()

virtual void SoDa::SoDaThread::run ( )
pure virtual

Each thread object must define its "run" loop.

This loop exits only when the thread has received a STOP command on one of its command mailboxes.

Implemented in SoDaTest::MultiMBox_Test_Thread, SoDa::BaseBandRX, SoDa::USRPCtrl, SoDa::BaseBandTX, SoDa::USRPTX, SoDa::USRPRX, SoDa::CWTX, SoDa::TestServer, SoDa::GPSmon, SoDa::UI, and SoDaTest::ThN.

◆ sigsegHandler()

static void SoDa::SoDaThread::sigsegHandler ( int  sig)
inlinestaticprivate

Definition at line 399 of file SoDaBase.hxx.

Referenced by hookSigSeg().

◆ start()

void SoDa::SoDaThread::start ( )
inline

Execute the threads run loop.

Definition at line 292 of file SoDaBase.hxx.

References outerRun().

Referenced by doWork(), and main().

◆ waitForJoin()

bool SoDa::SoDaThread::waitForJoin ( unsigned int  m)
inline

wait for the thread to stop running, or the specified time to pass.

Parameters
mtimeout in milliseconds
Returns
true if the thread has stopped, false otherwise.

Definition at line 313 of file SoDaBase.hxx.

Referenced by doWork().

Member Data Documentation

◆ th

boost::thread* SoDa::SoDaThread::th
private

Definition at line 368 of file SoDaBase.hxx.


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