![]() |
Base class to create thread aware classes. More...
#include <Thread.h>
Public Member Functions | |
Thread (const char *pType) | |
virtual | ~Thread () |
const char * | namePtr () const |
bool | dispatch () |
Lets the thread to start working. | |
int | join () |
Wait until the internal thread's memory structures are finished. | |
void | finish () |
Advise the thread for not continuing executing the perform method. | |
bool | finishRequested () const |
Indicates if a finish was executed on this thread. | |
void | relocate (string pDestination) |
Moves the thread to the specified destination. | |
![]() | |
string & | lastErrorRef () |
Returns a reference to the last stored error message. | |
ErrorCode | lastCode () |
Returns the last stored code. | |
bool | valid () |
Permits to know if the object has a valid internal state. | |
string & | typeRef () |
Permits to know the type of this particular object. | |
Protected Member Functions | |
Thread (const char *pType, string &pReceivedState) | |
This is the protected constructor will be used by the distributed rebuilder. | |
virtual bool | prepare ()=0 |
Provides a placeholder for the class to initialize internal data. | |
virtual int | perform ()=0 |
Performs the internal processing cycle for the thread. | |
virtual void | dispose ()=0 |
If the prepare and perform method where successful, the dispose must deinitialize everything was initialized during the prepare method. | |
virtual void | d_packState (string &pStateData) |
Permits to package the thread contents to be send to another process or computer to continue working. | |
virtual bool | d_sendToDestination (string &pStateData) |
Sends the thread state to the destination. | |
virtual void | d_restoreState (string &pSource) |
Rebuilds the internal state for the thread. | |
![]() | |
HSEPObject (const char *pType) | |
Constructor, providing the base for the state controlling instance. | |
virtual | ~HSEPObject () |
void | setLastError (string &pErrorMsgRef) |
Assigns an error message text to the last executed operation. | |
void | setLastError (const string &pErrorMsgRef) |
Assigns an error message text to the last executed operation. | |
void | setLastError (const char *pErrorMsg) |
Assigns an error message text to the last executed operation. | |
void | setValid () |
Defines that the object has a valid state. | |
void | setInvalid () |
Defines that the object has an invalid state. | |
void | setLastCode (const ErrorCode pErrorCode) |
Defines the internal result code for the object. | |
Protected Attributes | |
Mutex | aMutex |
Base class to create thread aware classes.
The descendant classes must implement the prepare, perform and dispose methods, that would offer the following type of functionality:
In the independent thread functionality
Where the thread must be accountable as finished
All the internal threading processing is hidden for the class user.
|
inline |
Definition at line 88 of file Thread.h.
References THREADNAME_LEN.
|
inlineprotected |
This is the protected constructor will be used by the distributed rebuilder.
pType | |
pReceivedState |
Definition at line 158 of file Thread.h.
References THREADNAME_LEN.
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
|
inlineprotectedvirtual |
bool HSEP::Thread::dispatch | ( | ) |
Lets the thread to start working.
If the operating system doesn't have enough resources, the dispatch attempts to start the thread 10 times with 10 milliseconds time between attempt. After that, if all the attempts fail, returns false.
Definition at line 72 of file Thread.cpp.
References NON_DISPATCHED.
Referenced by HSEP::Service::Service().
|
protectedpure virtual |
If the prepare and perform method where successful, the dispose must deinitialize everything was initialized during the prepare method.
Implemented in HSEP::LThread, and HSEP::ServiceThread.
|
inline |
|
inline |
int HSEP::Thread::join | ( | ) |
Wait until the internal thread's memory structures are finished.
Definition at line 119 of file Thread.cpp.
|
protectedpure virtual |
Performs the internal processing cycle for the thread.
Only works if the prepare method was successful.
Implemented in HSEP::LThread.
|
protectedpure virtual |
Provides a placeholder for the class to initialize internal data.
Implemented in HSEP::LThread, and HSEP::ServiceThread.
void HSEP::Thread::relocate | ( | string | pDestination | ) |
Moves the thread to the specified destination.
In this version, the relocation of threads have no effect. This is an advanced functionality to be developed in future versions to create completely mutable distributed programs that can distribute "part" of their functionality to other programs and/or other computers.
pDestination |
Definition at line 127 of file Thread.cpp.
|
mutableprotected |
Definition at line 168 of file Thread.h.
Referenced by HSEP::ServiceThread::log().