16 #ifndef SURGSIM_FRAMEWORK_BASICTHREAD_H 17 #define SURGSIM_FRAMEWORK_BASICTHREAD_H 22 #include <boost/thread.hpp> 23 #include <boost/chrono.hpp> 67 void start(std::shared_ptr<Barrier> startupBarrier =
nullptr,
bool isSynchronous =
false);
104 m_period = boost::chrono::duration<double>(1.0 / val);
169 #endif // SURGSIM_FRAMEWORK_BASICTHREAD_H boost::thread m_thisThread
Definition: BasicThread.h:142
boost::thread & getThread()
Definition: BasicThread.cpp:93
Definition: DriveElementFromInputBehavior.cpp:27
bool m_isSynchronous
Definition: BasicThread.h:150
bool isRunning() const
Query if this object is running.
Definition: BasicThread.cpp:64
bool waitForBarrier(bool success)
Definition: BasicThread.cpp:219
void start(std::shared_ptr< Barrier > startupBarrier=nullptr, bool isSynchronous=false)
C++11 introduced noexcept.
Definition: BasicThread.cpp:81
void stop()
Stopping the execution, blocks until the running thread has actually stopped,.
Definition: BasicThread.cpp:153
std::string getName() const
Definition: BasicThread.cpp:186
void setRate(double val)
Set the update rate of the thread.
Definition: BasicThread.h:102
bool startUp()
Trigger the startup of this object, this will be called after all other threads doInit() was called t...
Definition: BasicThread.cpp:76
virtual bool executeInitialization()
Definition: BasicThread.cpp:191
bool m_isIdle
Definition: BasicThread.h:146
bool m_isRunning
Definition: BasicThread.h:148
virtual void doBeforeStop()
Prepares the thread for its execution to be stopped.
Definition: BasicThread.cpp:247
string(TOUPPER ${DEVICE}DEVICE_UPPER_CASE) option(BUILD_DEVICE_ $
Definition: CMakeLists.txt:35
bool setSynchronous(bool val)
Sets the thread to synchronized execution in concert with the startup barrier, the startup barrier ha...
Definition: BasicThread.cpp:228
virtual bool doInitialize()=0
BasicThread(const std::string &name="Unknown Thread")
Definition: BasicThread.cpp:31
bool initialize()
Trigger the initialization of this object, this will be called before all other threads doStartup() a...
Definition: BasicThread.cpp:69
virtual ~BasicThread() noexcept(false)
C++11 introduced noexcept.
Definition: BasicThread.cpp:45
virtual bool doUpdate(double dt)
Implementation of actual work function for this thread, this has a default implementation to handle d...
Definition: BasicThread.cpp:242
void operator()()
This is what boost::thread executes on thread creation.
Definition: BasicThread.cpp:98
std::string m_name
Definition: BasicThread.h:140
bool m_isInitialized
Definition: BasicThread.h:147
bool isSynchronous()
Query if this object is synchronized.
Definition: BasicThread.cpp:237
Basic thread implementation, tries to maintain a constant rate, supplies startup an initialization...
Definition: BasicThread.h:47
bool isIdle()
Query if this thread is in idle state or not.
Definition: BasicThread.cpp:181
virtual bool doStartUp()=0
void setIdle(bool isIdle)
Set/Unset the thread in an idle state (doUpdate() called or not in the update() method) ...
Definition: BasicThread.cpp:176
bool m_stopExecution
Definition: BasicThread.h:149
std::shared_ptr< Barrier > m_startupBarrier
Definition: BasicThread.h:144
boost::chrono::duration< double > m_period
Definition: BasicThread.h:143
bool isInitialized()
Query if this object is initialized.
Definition: BasicThread.cpp:59