#include <Thread.h>
Inheritance diagram for OW32::CThread:
Public Member Functions | |
CThread (bool bAutoDelete=false) | |
Constructor for a CThread object. The AutoDelete flag should be set to true if you want `delete this' called at thread exit. It defaults to false, as you almost certainly don't want this :). | |
virtual | ~CThread () |
Default destructor that does nothing. | |
virtual unsigned int | Run ()=0 |
The thread run function to be overriden by the derived class. | |
virtual BOOL | InitInstance () |
This function is called just after the thread has started. | |
virtual void | ExitInstance () |
This function is called just after the Run function has finished execution. You can use it to provide per-thread cleanup. | |
bool | GetAutoDelete () |
Check if the thread is auto-deleting. | |
void | SetAutoDelete (bool bAutoDelete) |
Set the auto-delete flag for a thread. | |
BOOL | Create () |
Start up the thread. | |
void | Close () |
Close the encapsulated thread handle. | |
DWORD | Suspend () |
Suspend execution of the thread. | |
DWORD | Resume () |
Resume execution of the thread. | |
int | GetPriority () |
Get the current thread priority. | |
int | SetPriority (int nPriority) |
Set the current thread priority. | |
BOOL | PostMessage (UINT Msg, WPARAM wParam, LPARAM lParam) |
Post a message to the thread. | |
HANDLE | GetHandle () |
Return the thread handle. | |
DWORD | GetId () |
Return the thread Id. | |
BOOL | GetExitCode (LPDWORD lpExitCode) |
Return the thread's exit code. | |
operator HANDLE () | |
Extractor for the thread handle. | |
operator DWORD () | |
Extractor for the thread Id. |
This class provides a wrapper around the Win32 threading API. It encapsulates a thread object, which has a handle and a thread id. To use it, derive a class from CThread and override the Run() method.
This class uses the CRT _beginthreadex to ensure that CRT data structures are properly initialised and cleaned up. For this reason, do not use ExitThread(), instead use _endthread or _endthreadex should you wish to terminate the thread. You can also simply return from the Run() method. Also note that _endthread or _endthreadex will prevent the thread from auto-deleting.
|
Constructor for a CThread object. The AutoDelete flag should be set to true if you want `delete this' called at thread exit. It defaults to false, as you almost certainly don't want this :).
|
|
Close the encapsulated thread handle. You can do this after thread exit to return the state of this object to the default, in case it needs to be reused. |
|
Start up the thread.
|
|
Check if the thread is auto-deleting.
|
|
Return the thread's exit code.
|
|
Return the thread handle.
|
|
Return the thread Id.
|
|
Get the current thread priority.
|
|
This function is called just after the thread has started.
|
|
Extractor for the thread Id.
|
|
Extractor for the thread handle.
|
|
Post a message to the thread.
|
|
Resume execution of the thread.
|
|
The thread run function to be overriden by the derived class.
Implemented in OW32::CAsyncConnectionThread, and OW32::CIoCompletionThread. |
|
Set the auto-delete flag for a thread.
|
|
Set the current thread priority.
|
|
Suspend execution of the thread.
|