MDSTk Libraries  1.1.0
Medical Data Segmentation Toolkit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
mds::sys::CThread Class Reference

Encapsulation of several thread functions into a class mds::CThread. More...

#include <mdsThread.h>

Inheritance diagram for mds::sys::CThread:
Inheritance graph
[legend]

List of all members.

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 inttRoutine )(CThread *pThread)
 User thread routine.
typedef tRoutinetRoutinePtr
 Pointer to a user thread routine.

Public Member Functions

 CThread (tRoutinePtr pRoutine, void *pData=NULL, bool bRun=true)
 Constructor.
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 (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 ~CThread ()
 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.

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.

Detailed Description

Encapsulation of several thread functions into a class mds::CThread.


Member Typedef Documentation

User thread routine.

  • Please, call the method isExitSignalled() periodically to check if the routine should be terminated, or use the MDS_THREAD_MAIN_LOOP macro to implement this behaviour.

Pointer to a user thread routine.


Member Enumeration Documentation

anonymous enum [inherited]

Templates that require members of the CObject class can use this enum to check the existence.

Enumerator:
CLASS_OBJECT 
anonymous enum [inherited]

Signature used to recognize objects on the heap.

Enumerator:
HEAP_OBJECT 

Constructor & Destructor Documentation

mds::sys::CThread::CThread ( tRoutinePtr  pRoutine,
void *  pData = NULL,
bool  bRun = true 
)

Constructor.

virtual mds::sys::CThread::~CThread ( ) [virtual]

Destructor.


Member Function Documentation

void mds::base::CObject::addReference ( ) const [protected, inherited]

Increase the reference counter.

bool mds::base::CObject::delReference ( ) const [protected, inherited]

Decrease the reference counter.

  • Returns true if the decremented number of references is lower or equal to zero and object must be deleted.

Returns pointer to the user data.

Returns exit code returned by an user thread routine.

  • -1 if the thread is still running.

Returns the number of references.

Returns true if the thread is running.

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)

Waits for the thread termination.

Smart pointer type.

static void* mds::base::CObject::operator new ( std::size_t  Size) [static, inherited]

Allocates a new object on the heap.

Resumes the suspended thread.

void mds::sys::CThread::setData ( void *  pData)

Sets pointer to the user data.

Signals the exit event that controls the thread termination.

void mds::sys::CThread::setPriority ( EThreadPriority  ePriority)

Sets the thread priority.

Suspends the thread.

void mds::sys::CThread::terminate ( bool  bWait = true,
unsigned  uTime = THREAD_EXIT_TIME 
)

Terminates the thread.


Member Data Documentation

Thread suspended flag.

Critical section for mutual access.

Event the thread should check periodically and exit when it's set.

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.

  • Zero if there is no reference.

Event signalled if the thread is not paused.

void* mds::sys::CThread::m_pData [protected]

Pointer to user data.

Pointer to a user thread routine.

Event signalled when the thread has terminated.


The documentation for this class was generated from the following files: