-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcThread.cpp
More file actions
68 lines (57 loc) · 971 Bytes
/
cThread.cpp
File metadata and controls
68 lines (57 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "stdafx.h"
#include "cThread.h"
cLockable::cLockable()
{
InitializeCriticalSection(&m_csLock);
m_bLocked = false;
}
cLockable::~cLockable()
{
DeleteCriticalSection(&m_csLock);
}
void cLockable::Lock()
{
EnterCriticalSection(&m_csLock);
m_bLocked = true;
}
void cLockable::Unlock()
{
m_bLocked = false;
LeaveCriticalSection(&m_csLock);
}
bool cLockable::GetLocked()
{
return m_bLocked;
}
cThread::cThread()
{
m_bQuit = false;
m_bStopped = true;
m_hThread = 0;
}
cThread::~cThread()
{
if (m_hThread)
{
MessageBox(NULL, "Thread still open upon destructor call.", "cThread::~cThread() Error", MB_ICONERROR);
m_bQuit = true;
}
}
void cThread::Start()
{
m_bStopped = false;
m_hThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE) ThreadProc, this, NULL, &m_dwThreadID);
}
void cThread::Stop()
{
m_bQuit = true;
m_hThread = 0;
}
void cThread::SetStopped()
{
m_bStopped = true;
}
bool cThread::GetStopped()
{
return m_bStopped;
}