C++ common classes
General purpose classes for use across projects (Apache license)
CXPlatThread Class Reference

CXPlatThread.h: interface for the CXPlatThread class. More...

#include <CXPlatThread.h>

Inheritance diagram for CXPlatThread:
CDBPublisher CFlushLogThread CPHandler CUDPSocket CXPlatPooledThread CPClientHandler CPConnectionHandler

List of all members.

Public Types

enum  THREAD_STATUS {
  THREAD_SUCCESS = 0, NOT_STARTED = 1, SUSPENDED = 2, RESUMED = 3,
  RUNNING = 4, CANT_START = 5, ALREADY_SUSPENDED = 6, THREAD_TERMINATED = 7,
  NOT_SUPPORTED_ON_PLATFORM = 8, INVALID_REQUEST = 9, ALREADY_RUNNING = 10
}
 Current status of threads. More...

Public Member Functions

 CXPlatThread ()
virtual ~CXPlatThread ()
virtual THREAD_STATUS StartThread (void *pParam=NULL, BOOL bStartSuspended=FALSE)
virtual THREAD_STATUS SuspendThread ()
 Suspend thread.
virtual THREAD_STATUS ResumeThread ()
 Resume thread.
virtual XPLAT_HANDLE GetThreadHandle ()
 Return the thread handle.
virtual THREAD_STATUS GetThreadStatus ()
 Check to see if thread is active.
virtual DWORD WaitForThreadCompletion (DWORD dwTimeout=INFINITE)
 Wait for a thread to termintate.
virtual int GetThreadType ()
 Return a user defined thread type ID.
virtual int DetachThread ()
 You must either detach the thread or join it for proper cleanup.

Static Public Member Functions

static BOOL IsThreadActive (XPLAT_HANDLE hThread)
 Check to see if a thread is active.

Protected Member Functions

virtual unsigned WorkerFunction (void *pParam)=0
 Called by CXPlatThread to start work in object context.
void CloseThreadHandle ()
 Close handle.

Protected Attributes

BOOL bSuspended
XPLAT_HANDLE hThreadHandle
voidpUserParm
BOOL bDetached
BOOL bJoined

Detailed Description

CXPlatThread.h: interface for the CXPlatThread class.

Created: Richard A. Bross NOTES: On Unix platforms, every thread must be either detached or WaitForThreadCompletion(INFINITE) must be called for proper cleanup. If WaitForThreadCompletion is called with any timeout other than INFINITE, and it times out, you must then call either DetachThread or WaitForThreadCompletion(INFINITE) if you wish to ensure proper cleanup prior to detruction of the object..

However, if neither has been called, and the object is deleted the destructor will automatically call WaitForThreadCompletion(INFINITE). _MSC_VER >= 1000

Definition at line 43 of file CXPlatThread.h.


Member Enumeration Documentation

Current status of threads.

Enumerator:
THREAD_SUCCESS 
NOT_STARTED 
SUSPENDED 
RESUMED 
RUNNING 
CANT_START 
ALREADY_SUSPENDED 
THREAD_TERMINATED 
NOT_SUPPORTED_ON_PLATFORM 
INVALID_REQUEST 
ALREADY_RUNNING 

Trying to wait on a detached thread or detach a joined (WaitForThreadCompletion) thread.

Definition at line 50 of file CXPlatThread.h.


Constructor & Destructor Documentation

Definition at line 47 of file CXPlatThread.cpp.

Definition at line 57 of file CXPlatThread.cpp.


Member Function Documentation

Close handle.

Definition at line 268 of file CXPlatThread.cpp.

int CXPlatThread::DetachThread ( ) [virtual]

You must either detach the thread or join it for proper cleanup.

Definition at line 309 of file CXPlatThread.cpp.

Return the thread handle.

Definition at line 163 of file CXPlatThread.cpp.

Check to see if thread is active.

Definition at line 187 of file CXPlatThread.cpp.

int CXPlatThread::GetThreadType ( ) [virtual]

Return a user defined thread type ID.

Definition at line 260 of file CXPlatThread.cpp.

Check to see if a thread is active.

Definition at line 284 of file CXPlatThread.cpp.

Resume thread.

Definition at line 140 of file CXPlatThread.cpp.

CXPlatThread::THREAD_STATUS CXPlatThread::StartThread ( void pParam = NULL,
BOOL  bStartSuspended = FALSE 
) [virtual]

Start thread execution Passing the "this" pointer here is redundant: your WorkerFunction will be called in object context.

Definition at line 65 of file CXPlatThread.cpp.

Suspend thread.

Definition at line 115 of file CXPlatThread.cpp.

Wait for a thread to termintate.

Definition at line 211 of file CXPlatThread.cpp.

virtual unsigned CXPlatThread::WorkerFunction ( void pParam) [protected, pure virtual]

Called by CXPlatThread to start work in object context.

Implemented in CDBPublisher, CXPlatPooledThread, CPHandler, CUDPSocket, CPClientHandler, CPConnectionHandler, and CFlushLogThread.


Member Data Documentation

Definition at line 98 of file CXPlatThread.h.

Definition at line 99 of file CXPlatThread.h.

Definition at line 94 of file CXPlatThread.h.

Definition at line 95 of file CXPlatThread.h.

Definition at line 96 of file CXPlatThread.h.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines