GlobalObjects
|
Base class for a thread that executes its work endlessly until aborted. More...
#include <EuEndlessPThread.h>
Public Types | |
enum | EuPTHREAD_ORDER { EuPTHREAD_WORK , EuPTHREAD_TAKE_A_BREAK , EuPTHREAD_END } |
Public Types inherited from EuAPThread | |
enum | EuPTHREAD_STATUS { EuPTHREAD_AT_THE_START , EuPTHREAD_WORKING , EuPTHREAD_PAUSING , EuPTHREAD_FINISHED } |
Public Member Functions | |
EuEndlessPThread () | |
virtual | ~EuEndlessPThread () |
virtual int | cancel () |
virtual int | finishBreak () |
int | getBreakCounter () |
void | setExclusiveAccess () |
void | signalInput () |
virtual int | start () |
virtual int | takeABreak () |
void | unsetExclusiveAccess () |
void | waitForInput () |
Public Member Functions inherited from EuAPThread | |
EuAPThread () | |
virtual | ~EuAPThread () |
virtual int | join () |
EuAPThread::EuPTHREAD_STATUS | status () const |
void | testCancel () |
Protected Member Functions | |
void | takeABreakWait () |
Protected Member Functions inherited from EuAPThread | |
virtual void | cleanUp () |
virtual void | work ()=0 |
Static Protected Member Functions | |
static void * | threadWork (void *pParam) |
Static Protected Member Functions inherited from EuAPThread | |
static void | _cleanUp (void *pParam) |
Protected Attributes | |
bool | m_bInExluzivAccess |
pthread_cond_t | m_BreakCond |
EuPTHREAD_ORDER | m_eThreadOrder |
pthread_mutex_t | m_ExclusiveAccessMutex |
int | m_iBreakCounter |
sem_t | m_Semaphore |
Protected Attributes inherited from EuAPThread | |
EuPTHREAD_STATUS | m_eThreadStatus |
std::string | m_strDebugInfo |
pthread_t | m_Thread |
Private Member Functions | |
EuEndlessPThread (const EuEndlessPThread &) | |
EuEndlessPThread & | operator= (const EuEndlessPThread &) |
Base class for a thread that executes its work endlessly until aborted.
In subclasses, only the virtual method EuAPThread::work() must be overwritten.
Commands can be passed to a derived EuEndlessPThread after the start.
Enumerator | |
---|---|
EuPTHREAD_WORK | Thread should work. |
EuPTHREAD_TAKE_A_BREAK | Thread should skip working (not working, but also not aborting) |
EuPTHREAD_END | Thread should end. |
EuEndlessPThread::EuEndlessPThread | ( | ) |
Standard constructor.
|
virtual |
The destructor remove # m_ExclusiveAccessMutex, m_BreakCond and m_Semaphore from memory.
Destructor, see also the description of the superclasses.
eut::ErrorNException | If the thread is already started and not yet finished, an exception is thrown. |
|
private |
The copy constructor is not available.
|
virtual |
Terminates the thread.
Reimplemented from EuAPThread.
|
virtual |
Ends the processing pause ( if m_iBreakCounter == 0 ). Must have been initiated by takeABreak().
int EuEndlessPThread::getBreakCounter | ( | ) |
Return m_iBreakCounter.
|
private |
The assignment operator is not available.
void EuEndlessPThread::setExclusiveAccess | ( | ) |
Set a lock on his mutex. Must be released with unsetExclusiveAccess().
void EuEndlessPThread::signalInput | ( | ) |
Ends the wait without activity initiated by waitForInput().
|
virtual |
Starts the thread.
Implements EuAPThread.
|
virtual |
Sets m_eThreadOrder to EuPTHREAD_TAKE_A_BREAK. This method can be used to skip or not execute the processing.
Must be terminated by finishBreak().
|
protected |
Is needed in threadWork( void * pParam ) to pause.
|
staticprotected |
This method is needed in start().
[in] | pParam | In order for this static method to access the method EuAPThread::work(), a reference to the respective instance of an object of the EuEndlessPThread or subclass type is expected in pParam. |
void EuEndlessPThread::unsetExclusiveAccess | ( | ) |
Releases a lock on its mutex when set by setExclusiveAccess().
void EuEndlessPThread::waitForInput | ( | ) |
Lets the thread wait at a defined position without activity. Must be terminated again by signalInput().
|
protected |
To set a mutex this attribute is required.
|
protected |
This attribute is necessary to pause the thread.
|
protected |
A thread can be given a command which is set here.
|
protected |
This Thraed needs a mutex to protect local variables.
|
protected |
If a EuEndlessPThread is to be paused, this counter is incremented; it is decremented again on wakeup. At 0, the thread is woken up again.
This enables a nested sleep and wake up.
|
protected |
Can be used to prevent the thread from idling. This is not the same as pausing, where the thread just skips processing.