ReactOS 0.4.15-dev-7918-g2a2556c
CThread Class Reference

#include <thread.h>

Inheritance diagram for CThread:
Collaboration diagram for CThread:

Public Member Functions

 CThread ()
 
virtual ~CThread ()
 
BOOL PostMessage (UINT Msg, WPARAM wParam, LPARAM lParam)
 
virtual void Execute ()
 
virtual void Terminate ()
 
BOOL Terminated ()
 

Protected Attributes

BOOL bTerminated
 
DWORD dwThreadId
 
HANDLE hThread
 
ThreadData Data
 

Detailed Description

Definition at line 18 of file thread.h.

Constructor & Destructor Documentation

◆ CThread()

CThread::CThread ( )

Definition at line 27 of file thread.cpp.

28{
30 // Points to the class that is executed within thread
31 Data.ClassPtr = this;
32 // Create synchronization event
33 Data.hFinished = CreateEvent(NULL, TRUE, FALSE, NULL);
34
35 // FIXME: Do some error handling
36 assert(Data.hFinished != NULL);
37
38 // Create thread
40
41 // FIXME: Do some error handling
43}
HANDLE hThread
Definition: thread.h:29
BOOL bTerminated
Definition: thread.h:27
DWORD dwThreadId
Definition: thread.h:28
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define assert(x)
Definition: debug.h:53
DWORD WINAPI ThreadEntry(LPVOID parameter)
Definition: thread.cpp:16
#define CreateEvent
Definition: winbase.h:3748
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:729

◆ ~CThread()

CThread::~CThread ( )
virtual

Definition at line 46 of file thread.cpp.

47{
48 if ((hThread != NULL) && (Data.hFinished != NULL)) {
49 if (!bTerminated)
50 Terminate();
52 CloseHandle(Data.hFinished);
54 hThread = NULL;
55 }
56}
virtual void Terminate()
Definition: thread.cpp:71
#define CloseHandle
Definition: compat.h:739
#define INFINITE
Definition: serial.h:102
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82

Member Function Documentation

◆ Execute()

void CThread::Execute ( )
virtual

Reimplemented in CHttpClientThread, and CHttpDaemonThread.

Definition at line 59 of file thread.cpp.

60{
61 while (!bTerminated) Sleep(0);
62}
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
Definition: synch.c:790

◆ PostMessage()

BOOL CThread::PostMessage ( UINT  Msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 65 of file thread.cpp.

66{
68}
struct @1632 Msg[]
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define PostThreadMessage
Definition: winuser.h:5833

◆ Terminate()

void CThread::Terminate ( )
virtual

Definition at line 71 of file thread.cpp.

72{
74}

Referenced by ~CThread().

◆ Terminated()

BOOL CThread::Terminated ( )

Definition at line 77 of file thread.cpp.

78{
79 return bTerminated;
80}

Referenced by CHttpClientThread::Execute(), CHttpDaemonThread::Execute(), and Run().

Member Data Documentation

◆ bTerminated

BOOL CThread::bTerminated
protected

Definition at line 27 of file thread.h.

Referenced by CThread(), Execute(), Terminate(), Terminated(), and ~CThread().

◆ Data

ThreadData CThread::Data
protected

Definition at line 30 of file thread.h.

◆ dwThreadId

DWORD CThread::dwThreadId
protected

Definition at line 28 of file thread.h.

Referenced by CThread(), and PostMessage().

◆ hThread

HANDLE CThread::hThread
protected

Definition at line 29 of file thread.h.

Referenced by CThread(), and ~CThread().


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