crashrpt
reporting
crashrpt
CritSec.h
1
/*************************************************************************************
2
This file is a part of CrashRpt library.
3
Copyright (c) 2003-2013 The CrashRpt project authors. All Rights Reserved.
4
5
Use of this source code is governed by a BSD-style license
6
that can be found in the License.txt file in the root of the source
7
tree. All contributing project authors may
8
be found in the Authors.txt file in the root of the source tree.
9
***************************************************************************************/
10
11
// File: CritSec.h
12
// Description: Critical section wrapper classes. Code of CCritSec and CAutoLock classes
13
// is taken from DirectShow base classes and modified in some way.
14
// Authors: zexspectrum
15
// Date:
16
17
#ifndef _CRITSEC_H
18
#define _CRITSEC_H
19
20
#include "
Prefastdef.h
"
21
22
// wrapper for whatever critical section we have
23
class
CCritSec
24
{
25
// make copy constructor and assignment operator inaccessible
26
27
CCritSec
(
const
CCritSec
&refCritSec);
28
CCritSec
&operator=(
const
CCritSec
&refCritSec);
29
30
CRITICAL_SECTION m_CritSec;
31
32
public
:
33
34
CCritSec
()
35
{
36
InitializeCriticalSection(&m_CritSec);
37
};
38
39
~
CCritSec
()
40
{
41
DeleteCriticalSection(&m_CritSec);
42
}
43
44
void
Lock()
45
{
46
EnterCriticalSection(&m_CritSec);
47
};
48
49
void
Unlock()
50
{
51
LeaveCriticalSection(&m_CritSec);
52
};
53
};
54
55
// locks a critical section, and unlocks it automatically
56
// when the lock goes out of scope
57
class
CAutoLock
58
{
59
// make copy constructor and assignment operator inaccessible
60
61
CAutoLock
(
const
CAutoLock
&refAutoLock);
62
CAutoLock
&operator=(
const
CAutoLock
&refAutoLock);
63
64
protected
:
65
CCritSec
* m_pLock;
66
67
public
:
68
CAutoLock
(__in
CCritSec
* plock)
69
{
70
m_pLock = plock;
71
m_pLock->Lock();
72
};
73
74
~
CAutoLock
()
75
{
76
m_pLock->Unlock();
77
};
78
};
79
80
81
#endif //_CRITSEC_H
CAutoLock
Definition:
CritSec.h:57
CCritSec
Definition:
CritSec.h:23
Prefastdef.h
SAL macro switches.
Generated by
1.8.12