GlobalObjects
|
Abstract superclass for threads. More...
#include <EuAPThread.h>
Public Types | |
enum | EuPTHREAD_STATUS { EuPTHREAD_AT_THE_START , EuPTHREAD_WORKING , EuPTHREAD_PAUSING , EuPTHREAD_FINISHED } |
Public Member Functions | |
EuAPThread () | |
virtual | ~EuAPThread () |
virtual int | cancel () |
virtual int | join () |
virtual int | start ()=0 |
EuAPThread::EuPTHREAD_STATUS | status () const |
void | testCancel () |
Protected Member Functions | |
virtual void | cleanUp () |
virtual void | work ()=0 |
Static Protected Member Functions | |
static void | _cleanUp (void *pParam) |
Protected Attributes | |
EuPTHREAD_STATUS | m_eThreadStatus |
std::string | m_strDebugInfo |
pthread_t | m_Thread |
Private Member Functions | |
EuAPThread (const EuAPThread &) | |
EuAPThread & | operator= (const EuAPThread &) |
Abstract superclass for threads.
The work of the thread is done in the method EuAPThread::work(), which must be implemented by subclasses.
EuAPThread::EuAPThread | ( | ) |
Standard constructor.
|
virtual |
Destructor.
eut::ErrorNException | If the thread is already started and not yet finished, an exception is thrown. |
|
private |
The copy constructor is not available.
|
staticprotected |
This method is passed in subclasses in method threadWork to function pthread_cleanup_push, which expects a function (this one) and a void parameter to 'pass' (in this case the respective derived EuAPThread).
So when the pthread ends, this method is called with the respective thread as pParam (is the derived EuAPThread).
This static method in turn calls the dynamic method cleanUp of the derived EuAPThread (passed in pParam), which can perform the necessary cleanup work.
[in] | pParam | The respective derived EuAPThread. |
|
virtual |
Terminates the thread.
This method must be called before the destructor because other virtual methods may be called. This method can therefore not be placed in the destructor!
Reimplemented in EuEndlessPThread.
|
protectedvirtual |
If necessary cleanup work has to be performed, this method can be overwritten in the respective subclasses; it is called automatically.
Here m_eThreadStatus is set to EuPTHREAD_FINISHED.
|
virtual |
Is waiting until the thread is finished.
|
private |
The assignment operator is not available.
|
pure virtual |
Starts the thread.
Must be overwritten in subclasses, otherwise nothing happens.
Implemented in EuEndlessPThread.
EuAPThread::EuPTHREAD_STATUS EuAPThread::status | ( | ) | const |
Returns the status of the thread.
void EuAPThread::testCancel | ( | ) |
Checks whether the thread should be terminated (pthread_testcancel()).
|
protectedpure virtual |
This method is executed by the thread and must be overwritten in subclasses.
The method testCancel() should be inserted there to ensure that the thread is terminated.
|
protected |
The working status.
|
protected |
Here you can write something in for DEBUG purposes.
|
protected |
The 'real' pthread.