Commit 45a72207 authored by Ezekiel Dohmen's avatar Ezekiel Dohmen
Browse files

Fixing typo, and adding some comments

parent fd317c09
......@@ -8,24 +8,53 @@ class LIGO_Thread
{
public:
/**
* @brief This is the method that LIGO_Thread inheritors must implement
*
*/
virtual void thread_body() = 0;
/**
* @brief When this method is called, the thread is spawned and started.
* The caller will not be blocked, and can continue doing other work.
*
*/
void nonblocking_start()
{
_thread = std::thread(&LIGO_Thread::thread_body, this);
}
void blocking_satrt()
/**
* @brief When this method is called, the calling thread is blocked until
* the thread_body() implementation exits, usually signaled to do
* so by signal_stop()
*
*/
void blocking_start()
{
nonblocking_start();
join();
if(_joined == false)
{
join();
_joined = true;
}
}
/**
* @brief When this method is called, the _should_stop variable is set to stop.
* The thread_body() implementation should be checking should_stop() in
* its main loop and respond by exiting.
*
*/
void signal_stop()
{
_should_stop = true;
}
/**
* @brief Joins with an exited thread.
*
*/
void join()
{
if(_joined == false)
......@@ -35,10 +64,19 @@ class LIGO_Thread
}
}
/**
* @brief This method signals the thread to stop and waits for the thread
* join.
*
*/
void signal_stop_and_join()
{
signal_stop();
join();
if(_joined == false)
{
join();
_joined = true;
}
}
virtual ~LIGO_Thread() {}
......@@ -50,6 +88,11 @@ class LIGO_Thread
{
}
/**
* @brief The thread_body() implementation should be checking should_stop() in
* its main loop and respond by exiting when true.
*
*/
bool should_stop()
{
return _should_stop;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment