![]() |
SoDaRadio-12.2.0-cut_dependencies:6c82803
|
The Thread baseclass for all SoDa thread objects. More...
#include <SoDaThread.hxx>
Public Member Functions | |
| void | registerThread (SoDa::ThreadPtr me) |
| virtual void | subscribeToMailBoxes (const std::vector< MailBoxBasePtr > &mailboxes)=0 |
| the creator of this thread may offer one or more mailboxes to this object. | |
| void | operator() () |
| void | start () |
| Execute the thread's run loop. | |
| void | join () |
| more properly "Wait for this thread to exit its run loop". | |
| virtual void | run () |
| Each thread object must define its "run" loop. | |
| void | execCommand (CommandPtr cmd) |
| Execute (dispatch) a message removed from the command stream to one of the basic Command handler functions. | |
| virtual void | execGetCommand (CommandPtr cmd) |
| optional method to handle "GET" commands – commands that request a response | |
| virtual void | execSetCommand (CommandPtr cmd) |
| optional method to handle "SET" commands – commands that set internal state in the object. | |
| virtual void | execRepCommand (CommandPtr cmd) |
| optional method that reports status or the result of some action. | |
| virtual void | shutDown () |
| optional method that performs cleanup – may not delete. | |
| void | sleep_ms (unsigned int milliseconds) |
| void | sleep_us (unsigned int microseconds) |
| uint32_t | getID () |
| Get the process/thread ID for this thread – helps with figuring out who caused a segfault. | |
| Public Member Functions inherited from SoDa::Base | |
| Base (const std::string &oname) | |
| The constructor – pass a name for the object. | |
| void | registerSelf (BasePtr ptr) |
| std::string & | getObjName () |
| get the name of this object | |
| BasePtr | findSoDaObject (const std::string &oname) |
| find a SoDa Object by name. | |
| double | getTime () |
| Get a time stamp in nS resolution that monotonically increases and that is very inexpensive (typically < 100nS). | |
| BasePtr | getSelfPtr () |
| get a pointer to myself. | |
| 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 SoDa::Format &fmt, unsigned int threshold=1) |
| void | debugMsg (const char *msg, unsigned int threshold=1) |
| void | setDebugLevel (unsigned int v) |
| unsigned int | getDebugLevel () |
Protected Member Functions | |
| Thread (const std::string &oname, const std::string &version=std::string("12.2.0")) | |
| make the thread object. | |
| Protected Member Functions inherited from SoDa::Debug | |
| std::string | curDateTime () |
Protected Attributes | |
| std::weak_ptr< Thread > | self |
| A pointer to ourself. | |
| Protected Attributes inherited from SoDa::Debug | |
| std::string | unit_name |
| the name of the unit reporting status | |
| unsigned int | debug_level |
| the debug level (threshold) for messages | |
Private Member Functions | |
| void | outerRun () |
| the run method that is called by the thread handler. | |
| void | hookSigSeg () |
Static Private Member Functions | |
| static void | sigsegHandler (int sig) |
Private Attributes | |
| std::unique_ptr< std::thread > | thread_ptr |
| This is the actual thread object –. | |
| std::string | version |
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 std::mutex | debug_msg_mutex |
| Static Protected Attributes inherited from SoDa::Debug | |
| static unsigned int | default_debug_level |
| static unsigned int | global_debug_level |
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 79 of file SoDaThread.hxx.
|
protected |
make the thread object.
Register it by name and store a version string, so we can test it against the current version of the SoDaServer.
| oname | The name of the thread. |
| version | a string of the form "M.m.p" where M is the major version, m is minor, and p is patch. |
Invoking this thread should always leave the version parameter as the default. This is a hack to get the actual version information from the included file (used for the build) rather than from the shared library.
This constructor is only called by derived types.
References version.
| void SoDa::Thread::execCommand | ( | CommandPtr | cmd | ) |
|
inlinevirtual |
optional method to handle "GET" commands – commands that request a response
Reimplemented in CommandMonitor, SimpleAccessory, SoDa::BaseBandRX, SoDa::BaseBandTX, SoDa::CWTX, SoDa::IFRecorder, SoDa::RadioControl, SoDa::RadioRX, SoDa::RadioTX, and SoDa::UI.
Definition at line 155 of file SoDaThread.hxx.
|
inlinevirtual |
optional method that reports status or the result of some action.
Reimplemented in CommandMonitor, SimpleAccessory, SoDa::BaseBandRX, SoDa::BaseBandTX, SoDa::CWTX, SoDa::IFRecorder, SoDa::RadioControl, SoDa::RadioRX, SoDa::RadioTX, and SoDa::UI.
Definition at line 165 of file SoDaThread.hxx.
|
inlinevirtual |
optional method to handle "SET" commands – commands that set internal state in the object.
Reimplemented in CommandMonitor, SimpleAccessory, SoDa::BaseBandRX, SoDa::BaseBandTX, SoDa::CWTX, SoDa::IFRecorder, SoDa::RadioControl, SoDa::RadioRX, SoDa::RadioTX, and SoDa::UI.
Definition at line 160 of file SoDaThread.hxx.
| uint32_t SoDa::Thread::getID | ( | ) |
Get the process/thread ID for this thread – helps with figuring out who caused a segfault.
|
private |
|
inline |
more properly "Wait for this thread to exit its run loop".
returns after the thread has received a STOP message.
Definition at line 128 of file SoDaThread.hxx.
References thread_ptr.
|
inline |
Definition at line 112 of file SoDaThread.hxx.
References outerRun().
|
private |
the run method that is called by the thread handler.
This method wraps the thread objects run loop in an exception handler so that we can do something useful with it.
We call the subclass's "run" method inside a wrapper that can give us some limited information about what happened.
Referenced by operator()(), and start().
| void SoDa::Thread::registerThread | ( | SoDa::ThreadPtr | me | ) |
|
inlinevirtual |
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.
Reimplemented in CommandMonitor, IFServer, SimpleAccessory, SoDa::AudioQt, SoDa::BaseBandRX, SoDa::BaseBandTX, SoDa::CWTX, SoDa::IFRecorder, SoDa::RadioControl, SoDa::RadioRX, SoDa::RadioTX, and SoDa::UI.
Definition at line 137 of file SoDaThread.hxx.
References SoDa::Base::getObjName().
|
inlinevirtual |
optional method that performs cleanup – may not delete.
Reimplemented in CommandMonitor, IFServer, and SimpleAccessory.
Definition at line 170 of file SoDaThread.hxx.
|
staticprivate |
|
inline |
Definition at line 174 of file SoDaThread.hxx.
|
inline |
Definition at line 177 of file SoDaThread.hxx.
|
inline |
Execute the thread's run loop.
Definition at line 120 of file SoDaThread.hxx.
References outerRun(), and thread_ptr.
|
pure virtual |
the creator of this thread may offer one or more mailboxes to this object.
The thread may "subscribe" to the mailboxes as it chooses.
| mailboxes | A list of all mailboxes that we know about. |
Implemented in SoDa::AudioQt, SoDa::BaseBandRX, SoDa::BaseBandTX, SoDa::CWTX, SoDa::IFRecorder, SoDa::RadioControl, SoDa::RadioRX, SoDa::RadioTX, and SoDa::UI.
|
protected |
A pointer to ourself.
Definition at line 193 of file SoDaThread.hxx.
|
private |
This is the actual thread object –.
Definition at line 199 of file SoDaThread.hxx.
|
private |
Definition at line 216 of file SoDaThread.hxx.
Referenced by Thread().