39#include <condition_variable>
41#include <SoDa/MailBox.hxx>
97 Thread(
const std::string & oname,
const std::string &
version = std::string(SoDaRadio_VERSION));
138 std::cerr <<
"Thread " <<
getObjName() <<
" has no run method\n";
175 std::this_thread::sleep_for(std::chrono::milliseconds(milliseconds));
178 std::this_thread::sleep_for(std::chrono::microseconds(microseconds));
222 SDR::
Exception(
SoDa::Format(
"Mailbox %0 could not be found.").addS(mbox_name).str(),
The Baseclass for all SoDa objects, and useful commonly used classes.
Base(const std::string &oname)
The constructor – pass a name for the object.
std::string & getObjName()
get the name of this object
This is a list of all the commands that can "do something" to one or more components in the SoDa radi...
Debug(std::string _unit_name=std::string("UNKNOWN"))
MissingMailBox(const std::string &mbox_name, BasePtr thrower)
The SoDa::SDR Exception class (to distinguish it from the SoDaLibrary SoDa::Exception class.
Exception(const std::string &_reason, BasePtr obj=NULL)
The constructor.
BasePtr thrower
who caused the exception, if anyone?
The Thread baseclass for all SoDa thread objects.
void registerThread(SoDa::ThreadPtr me)
void join()
more properly "Wait for this thread to exit its run loop".
virtual void execRepCommand(CommandPtr cmd)
optional method that reports status or the result of some action.
Thread(const std::string &oname, const std::string &version=std::string("12.2.0"))
make the thread object.
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.
void start()
Execute the thread's run loop.
void outerRun()
the run method that is called by the thread handler.
virtual void run()
Each thread object must define its "run" loop.
std::unique_ptr< std::thread > thread_ptr
This is the actual thread object –.
std::weak_ptr< Thread > self
A pointer to ourself.
virtual void shutDown()
optional method that performs cleanup – may not delete.
virtual void execSetCommand(CommandPtr cmd)
optional method to handle "SET" commands – commands that set internal state in the object.
virtual void subscribeToMailBoxes(const std::vector< MailBoxBasePtr > &mailboxes)=0
the creator of this thread may offer one or more mailboxes to this object.
virtual void execGetCommand(CommandPtr cmd)
optional method to handle "GET" commands – commands that request a response
void execCommand(CommandPtr cmd)
Execute (dispatch) a message removed from the command stream to one of the basic Command handler func...
static void sigsegHandler(int sig)
std::shared_ptr< Thread > ThreadPtr
std::shared_ptr< Command > CommandPtr
std::shared_ptr< Base > BasePtr
std::weak_ptr< Thread > ThreadWeakPtr