ReactOS  0.4.15-dev-3207-ga415bd4
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
42  assert(hThread != NULL);
43 }
#define CreateEvent
Definition: winbase.h:3604
DWORD(WINAPI * LPTHREAD_START_ROUTINE)(LPVOID)
Definition: winbase.h:723
#define TRUE
Definition: types.h:120
#define assert(x)
Definition: debug.h:53
#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:136
BOOL bTerminated
Definition: thread.h:27
HANDLE hThread
Definition: thread.h:29
DWORD WINAPI ThreadEntry(LPVOID parameter)
Definition: thread.cpp:16
#define NULL
Definition: types.h:112
DWORD dwThreadId
Definition: thread.h:28

◆ ~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();
51  WaitForSingleObject(Data.hFinished, INFINITE);
52  CloseHandle(Data.hFinished);
54  hThread = NULL;
55  }
56 }
#define CloseHandle
Definition: compat.h:598
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL bTerminated
Definition: thread.h:27
HANDLE hThread
Definition: thread.h:29
#define NULL
Definition: types.h:112
virtual void Terminate()
Definition: thread.cpp:71
#define INFINITE
Definition: serial.h:102

Member Function Documentation

◆ Execute()

void CThread::Execute ( )
virtual

Reimplemented in CHttpDaemonThread, and CHttpClientThread.

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
BOOL bTerminated
Definition: thread.h:27

◆ PostMessage()

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

Definition at line 65 of file thread.cpp.

66 {
68 }
WPARAM wParam
Definition: combotst.c:138
#define PostThreadMessage
Definition: winuser.h:5809
struct @1586 Msg[]
DWORD dwThreadId
Definition: thread.h:28
LPARAM lParam
Definition: combotst.c:139

◆ Terminate()

void CThread::Terminate ( )
virtual

Definition at line 71 of file thread.cpp.

72 {
73  bTerminated = TRUE;
74 }
#define TRUE
Definition: types.h:120
BOOL bTerminated
Definition: thread.h:27

Referenced by ~CThread().

◆ Terminated()

BOOL CThread::Terminated ( )

Definition at line 77 of file thread.cpp.

78 {
79  return bTerminated;
80 }
BOOL bTerminated
Definition: thread.h:27

Referenced by 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: