-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcmutexobject.cpp
More file actions
53 lines (46 loc) · 2.44 KB
/
cmutexobject.cpp
File metadata and controls
53 lines (46 loc) · 2.44 KB
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
//****************************************************************************************************
//подключаемые библиотеки
//****************************************************************************************************
#include "cmutexobject.h"
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//конструктор и деструктор класса
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//----------------------------------------------------------------------------------------------------
//конструктор
//----------------------------------------------------------------------------------------------------
CMutexObject::CMutexObject(void)
{
InitializeCriticalSection(&CriticalSection);
}
//----------------------------------------------------------------------------------------------------
//конструктор копирования
//----------------------------------------------------------------------------------------------------
CMutexObject::CMutexObject(const CMutexObject& cMutex)
{
//нам нужно создать новый мютекс
InitializeCriticalSection(&CriticalSection);
}
//----------------------------------------------------------------------------------------------------
//деструктор
//----------------------------------------------------------------------------------------------------
CMutexObject::~CMutexObject()
{
DeleteCriticalSection(&CriticalSection);
}
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//закрытые функции класса
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//----------------------------------------------------------------------------------------------------
//заблокировать мютекс
//----------------------------------------------------------------------------------------------------
void CMutexObject::Lock(void)
{
EnterCriticalSection(&CriticalSection);
}
//----------------------------------------------------------------------------------------------------
//разблокировать мютекс
//----------------------------------------------------------------------------------------------------
void CMutexObject::Unlock(void)
{
LeaveCriticalSection(&CriticalSection);
}