#include <thread.h>
Inheritance diagram for Thread:
Public Member Functions | |
Thread () | |
ctor | |
virtual | ~Thread () |
dtor | |
int | start () |
Start the thread. | |
void | wait () |
Wait for the thread to finish (no timeout!). | |
void | stop () |
Gracefully stop the thread. | |
void | quit () |
Forcibly stop thread. | |
bool | running () const |
Is the thread running? | |
Protected Member Functions | |
virtual void | run ()=0 |
The thread mainloop. | |
Protected Attributes | |
bool | m_run |
pthread_t | m_pthread |
Static Private Member Functions | |
static void * | start_thread (void *) |
To create a threaded object derive from this class and implement the run member function. Check as often as you can the m_run member variable and immediately return from the function if it is set to false.
Yes, I know that there are numerous libraries that do the same and better. But I find it essential to keep the dependencies as low as possible for thin clients.
Definition at line 36 of file thread.h.
|
ctor
Definition at line 22 of file thread.cpp. |
|
dtor
Definition at line 26 of file thread.cpp. |
|
Forcibly stop thread. Not recommended as this might leak resources Definition at line 52 of file thread.cpp. |
|
The thread mainloop. This pure virtual function has to be implemented by the thread. Put your mainloop in here. Frequently check the m_run flag. If false immediately return.
Implemented in DMMClass, Escort97, GDM703, M9803R, MetexAscii, PeakTech10Ascii, and VC820. Referenced by start_thread(). |
|
Is the thread running?
Definition at line 62 of file thread.h. References m_run. |
|
Start the thread.
Definition at line 39 of file thread.cpp. References m_pthread, m_run, and start_thread(). Referenced by MetexAscii::MetexAscii(), MetexAscii::run(), and GDM703::run(). |
|
pthreads need a "C" compatible function pointer. This static function wraps the class member run. Definition at line 30 of file thread.cpp. References run(). Referenced by start(). |
|
Gracefully stop the thread.
Definition at line 54 of file thread.h. References m_run. |
|
Wait for the thread to finish (no timeout!).
Definition at line 47 of file thread.cpp. References m_pthread. |
|
|
|
Definition at line 65 of file thread.h. Referenced by VC820::run(), PeakTech10Ascii::run(), MetexAscii::run(), M9803R::run(), GDM703::run(), Escort97::run(), running(), start(), and stop(). |