#include <stoppable_thread.h>
A stoppable C++11 thread implementation.
Definition at line 49 of file stoppable_thread.h.
◆ StoppableThread()
StoppableThread::StoppableThread |
( |
| ) |
|
|
default |
◆ ~StoppableThread()
virtual StoppableThread::~StoppableThread |
( |
| ) |
|
|
virtualdefault |
◆ Run()
virtual void StoppableThread::Run |
( |
| ) |
|
|
pure virtual |
◆ RunInternal()
void StoppableThread::RunInternal |
( |
| ) |
|
|
inlineprivate |
◆ Running()
bool StoppableThread::Running |
( |
| ) |
|
|
inline |
Returns the current state of the thread.
- Returns
- true if running
Definition at line 117 of file stoppable_thread.h.
◆ Sleep()
template<class Rep , class Period >
void StoppableThread::Sleep |
( |
const std::chrono::duration< Rep, Period > & |
d | ) |
|
|
inline |
Sleep for the given duration, use literals like 1s, 100ms, 10us.
Definition at line 110 of file stoppable_thread.h.
◆ Start()
bool StoppableThread::Start |
( |
bool |
exc_info = false | ) |
|
|
inline |
Start the thread.
- Parameters
-
exc_info | prints a catched exception message to stderr |
- Returns
- true if thread was started, false if not
Definition at line 58 of file stoppable_thread.h.
◆ Stop()
void StoppableThread::Stop |
( |
bool |
wait = false | ) |
|
|
inline |
Stop the thread, needs call(s) to StopRequested() in the Run() worker function to check for the stop request.
- Parameters
-
wait | wait for the thread to end |
Definition at line 82 of file stoppable_thread.h.
◆ StopRequested()
bool StoppableThread::StopRequested |
( |
| ) |
|
|
inline |
Returns if a stop was requested.
- Returns
- true if a stop was requested
Definition at line 121 of file stoppable_thread.h.
◆ m_running
std::atomic_bool StoppableThread::m_running {false} |
|
private |
◆ m_stop
std::atomic_bool StoppableThread::m_stop {false} |
|
private |
◆ m_thread
std::thread StoppableThread::m_thread |
|
private |
The documentation for this class was generated from the following file: