24 #ifndef SIMPLETHREADHANDLER_H
25 #define SIMPLETHREADHANDLER_H
32 #define CHECK_CANCEL_THREAD { if (cancelThread()) {return;} }
33 #define CANCEL_THREAD { setCancelThread(true); return; }
89 void msleep(
double milliseconds);
101 #endif // SIMPLETHREADHANDLER_H
virtual void stop()
Stop the thread.
bool mCancelThread
Cancel flag.
void msleep(double milliseconds)
Sleep function for staying idle.
SimpleThreadHandler()
Constructor.
virtual void exceptionCaught(const EptException &e)
EPT exception handling.
virtual ~SimpleThreadHandler()
virtual destructor calls stop
bool isThreadRunning() const
Flag to check if the thread is running.
static void setThreadName(std::string s)
Specify the name of the thread.
std::thread mThread
Local thread member variable.
virtual void start()
Start the thread.
void simpleWorkerFunction()
Private helper function.
void setCancelThread(bool b)
Cancel-flag setter method, thread-safe.
std::mutex mLockMutex
Mutex protecting the cancel flag.
std::atomic< bool > mRunning
Is the thread running.
virtual void workerFunction()=0
Virtual worker function, executed within the new thread.
bool cancelThread() const
Cancel-flag getter method, thread-safe.