C++ common classes
General purpose classes for use across projects (Apache license)
|
CXPlatThread.h: interface for the CXPlatThread class. More...
#include <CXPlatThread.h>
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 |
void * | pUserParm |
BOOL | bDetached |
BOOL | bJoined |
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.
Current status of threads.
Definition at line 50 of file CXPlatThread.h.
Definition at line 47 of file CXPlatThread.cpp.
CXPlatThread::~CXPlatThread | ( | ) | [virtual] |
Definition at line 57 of file CXPlatThread.cpp.
void CXPlatThread::CloseThreadHandle | ( | ) | [protected] |
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.
XPLAT_HANDLE CXPlatThread::GetThreadHandle | ( | ) | [virtual] |
Return the thread handle.
Definition at line 163 of file CXPlatThread.cpp.
CXPlatThread::THREAD_STATUS CXPlatThread::GetThreadStatus | ( | ) | [virtual] |
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.
BOOL CXPlatThread::IsThreadActive | ( | XPLAT_HANDLE | hThread | ) | [static] |
Check to see if a thread is active.
Definition at line 284 of file CXPlatThread.cpp.
CXPlatThread::THREAD_STATUS CXPlatThread::ResumeThread | ( | ) | [virtual] |
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.
CXPlatThread::THREAD_STATUS CXPlatThread::SuspendThread | ( | ) | [virtual] |
Suspend thread.
Definition at line 115 of file CXPlatThread.cpp.
DWORD CXPlatThread::WaitForThreadCompletion | ( | DWORD | dwTimeout = INFINITE | ) | [virtual] |
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.
BOOL CXPlatThread::bDetached [protected] |
Definition at line 98 of file CXPlatThread.h.
BOOL CXPlatThread::bJoined [protected] |
Definition at line 99 of file CXPlatThread.h.
BOOL CXPlatThread::bSuspended [protected] |
Definition at line 94 of file CXPlatThread.h.
XPLAT_HANDLE CXPlatThread::hThreadHandle [protected] |
Definition at line 95 of file CXPlatThread.h.
void* CXPlatThread::pUserParm [protected] |
Definition at line 96 of file CXPlatThread.h.