ReactOS  0.4.15-dev-3173-g40ee59d
fxlock.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxLock.hpp
8 
9 Abstract:
10 
11  This is the C++ header for the FxLock
12 
13  This represents a container for handling locking
14 
15 Author:
16 
17 
18 
19 
20 Revision History:
21 
22 
23 --*/
24 
25 #ifndef _FXLOCK_H_
26 #define _FXLOCK_H_
27 
48 class FxLock {
49 
50 private:
52 
53  // For Verifier
55 
56 public:
58  VOID
59  )
60  {
61 
62 
63 
64 
66  m_Verifier = NULL;
67  }
68 
69  VOID
70  Initialize(
71  __in FxObject * ParentObject
72  );
73 
75  {
76  if (m_Verifier != NULL) {
77  delete m_Verifier;
78  }
79  }
80 
81  _When_(this->m_Verifier == NULL, _Acquires_lock_(this->m_lock))
82  inline
83  VOID
84  Lock(
85  __out PKIRQL PreviousIrql
86  )
87  {
88  if (m_Verifier != NULL) {
89  m_Verifier->Lock(PreviousIrql, FALSE);
90  }
91  // else if (PreviousIrql == NULL) {
92  // KeAcquireSpinLockAtDpcLevel(&m_lock);
93  // }
94  else {
95  m_lock.Acquire(PreviousIrql);
96  }
97  }
98 
99  _When_(this->m_Verifier == NULL, _Releases_lock_(this->m_lock))
100  inline
101  void
102  Unlock(
103  __in KIRQL PreviousIrql
104  )
105  {
106  if (m_Verifier != NULL) {
107  m_Verifier->Unlock(PreviousIrql, FALSE);
108  }
109  // else if (AtDpc) {
110  // KeReleaseSpinLockFromDpcLevel(&m_lock);
111  // }
112  else {
113  m_lock.Release(PreviousIrql);
114  }
115  }
116 
117  _When_(this->m_Verifier == NULL, _Acquires_lock_(this->m_lock))
118  inline
119  VOID
120  LockAtDispatch(
121  VOID
122  )
123  {
124  if (m_Verifier != NULL) {
125  KIRQL previousIrql;
126 
127  m_Verifier->Lock(&previousIrql, TRUE);
128  }
129  else {
130  m_lock.AcquireAtDpcLevel();
131  }
132  }
133 
134  _When_(this->m_Verifier == NULL, _Releases_lock_(this->m_lock))
135  inline
136  void
137  UnlockFromDispatch(
138  VOID
139  )
140  {
141  if (m_Verifier != NULL) {
143  }
144  else {
145  m_lock.ReleaseFromDpcLevel();
146  }
147  }
148 };
149 
150 #endif // _FXLOCK_H_
#define TRUE
Definition: types.h:120
VOID Unlock(__in KIRQL PreviousIrql, __in BOOLEAN AtDpc)
UCHAR KIRQL
Definition: env_spec_w32.h:591
MxLock m_lock
Definition: fxlock.hpp:51
#define FALSE
Definition: types.h:117
_When_(this->m_Verifier==NULL, _Releases_lock_(this->m_lock)) inline void Unlock(__in KIRQL PreviousIrql)
Definition: fxlock.hpp:99
#define _Releases_lock_(a)
Definition: btrfs_drv.h:208
VOID Lock(__out PKIRQL PreviousIrql, __in BOOLEAN AtDpc)
#define __out
Definition: dbghelp.h:62
_When_(this->m_Verifier==NULL, _Acquires_lock_(this->m_lock)) inline VOID Lock(__out PKIRQL PreviousIrql)
Definition: fxlock.hpp:81
FxVerifierLock * m_Verifier
Definition: fxlock.hpp:54
_When_(this->m_Verifier==NULL, _Acquires_lock_(this->m_lock)) inline VOID LockAtDispatch(VOID)
Definition: fxlock.hpp:117
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
_When_(this->m_Verifier==NULL, _Releases_lock_(this->m_lock)) inline void UnlockFromDispatch(VOID)
Definition: fxlock.hpp:134
Definition: mxlock.h:101
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
VOID Initialize(__in FxObject *ParentObject)
Definition: fxlock.cpp:29
#define NULL
Definition: types.h:112
FxLock(VOID)
Definition: fxlock.hpp:57
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
~FxLock()
Definition: fxlock.hpp:74
#define _Acquires_lock_(lock)
__inline VOID Initialize()
Definition: mxlockkm.h:43
#define __in
Definition: dbghelp.h:35