MDSTk Libraries
1.1.0
Medical Data Segmentation Toolkit
|
Thread encapsulation. More...
#include <mdsUserThread.h>
Public Types | |
enum | { CLASS_OBJECT } |
Templates that require members of the CObject class can use this enum to check the existence. More... | |
enum | { HEAP_OBJECT = 0x70616568 } |
Signature used to recognize objects on the heap. More... | |
typedef int( | tRoutine )(CThread *pThread) |
User thread routine. | |
typedef tRoutine * | tRoutinePtr |
Pointer to a user thread routine. | |
Public Member Functions | |
CUserThread (void *pData=NULL, bool bRun=true) | |
Default constructor. | |
virtual int | entry ()=0 |
Entry point of the thread. | |
void * | getData () |
Returns pointer to the user data. | |
int | getExitCode () |
Returns exit code returned by an user thread routine. | |
int | getReferencesCount () const |
Returns the number of references. | |
bool | isActive () |
Returns true if the thread is running. | |
bool | isExitSignalled () |
Returns true if the exit event is already signalled. | |
bool | isOnHeap () const |
Returns true if the object is allocated on the heap. | |
bool | join (unsigned uTimeout) |
Waits for the thread termination. | |
MDS_SHAREDPTR (CUserThread) | |
Smart pointer type. | |
MDS_SHAREDPTR (CThread) | |
Smart pointer type. | |
void | resume () |
Resumes the suspended thread. | |
void | setData (void *pData) |
Sets pointer to the user data. | |
void | setExitEvent () |
Signals the exit event that controls the thread termination. | |
void | setPriority (EThreadPriority ePriority) |
Sets the thread priority. | |
void | suspend () |
Suspends the thread. | |
void | terminate (bool bWait=true, unsigned uTime=THREAD_EXIT_TIME) |
Terminates the thread. | |
virtual | ~CUserThread () |
Virtual destructor. | |
Static Public Member Functions | |
static void * | operator new (std::size_t Size) |
Allocates a new object on the heap. | |
Protected Member Functions | |
void | addReference () const |
Increase the reference counter. | |
bool | delReference () const |
Decrease the reference counter. | |
Static Protected Member Functions | |
static int | threadRoutine (mds::sys::CThread *pThread) |
Real thread routine. | |
Protected Attributes | |
bool | m_bSuspended |
Thread suspended flag. | |
CCriticalSection | m_CritSec |
Critical section for mutual access. | |
CEvent | m_ExitEvent |
Event the thread should check periodically and exit when it's set. | |
int | m_iExitCode |
Thread exit code. | |
int | m_iHeapObject |
Flag initialized if the object is on the heap. | |
int | m_iReferences |
The number of references to the object. | |
CEvent | m_NotSuspendedEvent |
Event signalled if the thread is not paused. | |
void * | m_pData |
Pointer to user data. | |
tRoutinePtr | m_pRoutine |
Pointer to a user thread routine. | |
CEvent | m_TerminatedEvent |
Event signalled when the thread has terminated. |
Thread encapsulation.
Internal thread routine calls a virtual method that may be overloaded.
typedef int( mds::sys::CThread::tRoutine)(CThread *pThread) [inherited] |
User thread routine.
typedef tRoutine* mds::sys::CThread::tRoutinePtr [inherited] |
Pointer to a user thread routine.
anonymous enum [inherited] |
Templates that require members of the CObject class can use this enum to check the existence.
mds::sys::CUserThread::CUserThread | ( | void * | pData = NULL , |
bool | bRun = true |
||
) |
Default constructor.
mds::sys::CUserThread::~CUserThread | ( | ) | [virtual] |
Virtual destructor.
void mds::base::CObject::addReference | ( | ) | const [protected, inherited] |
Increase the reference counter.
bool mds::base::CObject::delReference | ( | ) | const [protected, inherited] |
Decrease the reference counter.
virtual int mds::sys::CUserThread::entry | ( | ) | [pure virtual] |
Entry point of the thread.
This function is pure virtual and must be implemented by any derived class. The thread execution is going to start here.
void* mds::sys::CThread::getData | ( | ) | [inherited] |
Returns pointer to the user data.
int mds::sys::CThread::getExitCode | ( | ) | [inherited] |
Returns exit code returned by an user thread routine.
int mds::base::CObject::getReferencesCount | ( | ) | const [inherited] |
Returns the number of references.
bool mds::sys::CThread::isActive | ( | ) | [inherited] |
Returns true if the thread is running.
bool mds::sys::CThread::isExitSignalled | ( | ) | [inherited] |
Returns true if the exit event is already signalled.
bool mds::base::CObject::isOnHeap | ( | ) | const [inherited] |
Returns true if the object is allocated on the heap.
bool mds::sys::CThread::join | ( | unsigned | uTimeout | ) | [inherited] |
Waits for the thread termination.
Smart pointer type.
mds::sys::CThread::MDS_SHAREDPTR | ( | CThread | ) | [inherited] |
Smart pointer type.
static void* mds::base::CObject::operator new | ( | std::size_t | Size | ) | [static, inherited] |
Allocates a new object on the heap.
void mds::sys::CThread::resume | ( | ) | [inherited] |
Resumes the suspended thread.
void mds::sys::CThread::setData | ( | void * | pData | ) | [inherited] |
Sets pointer to the user data.
void mds::sys::CThread::setExitEvent | ( | ) | [inherited] |
Signals the exit event that controls the thread termination.
void mds::sys::CThread::setPriority | ( | EThreadPriority | ePriority | ) | [inherited] |
Sets the thread priority.
void mds::sys::CThread::suspend | ( | ) | [inherited] |
Suspends the thread.
void mds::sys::CThread::terminate | ( | bool | bWait = true , |
unsigned | uTime = THREAD_EXIT_TIME |
||
) | [inherited] |
Terminates the thread.
int mds::sys::CUserThread::threadRoutine | ( | mds::sys::CThread * | pThread | ) | [static, protected] |
Real thread routine.
bool mds::sys::CThread::m_bSuspended [protected, inherited] |
Thread suspended flag.
CCriticalSection mds::sys::CThread::m_CritSec [protected, inherited] |
Critical section for mutual access.
CEvent mds::sys::CThread::m_ExitEvent [protected, inherited] |
Event the thread should check periodically and exit when it's set.
int mds::sys::CThread::m_iExitCode [protected, inherited] |
Thread exit code.
int mds::base::CObject::m_iHeapObject [mutable, protected, inherited] |
Flag initialized if the object is on the heap.
int mds::base::CObject::m_iReferences [mutable, protected, inherited] |
The number of references to the object.
CEvent mds::sys::CThread::m_NotSuspendedEvent [protected, inherited] |
Event signalled if the thread is not paused.
void* mds::sys::CThread::m_pData [protected, inherited] |
Pointer to user data.
tRoutinePtr mds::sys::CThread::m_pRoutine [protected, inherited] |
Pointer to a user thread routine.
CEvent mds::sys::CThread::m_TerminatedEvent [protected, inherited] |
Event signalled when the thread has terminated.