ReactOS 0.4.15-dev-7842-g558ab78
FxTransactionedList Class Referenceabstract

#include <fxtransactionedlist.hpp>

Inheritance diagram for FxTransactionedList:
Collaboration diagram for FxTransactionedList:

Public Member Functions

 FxTransactionedList ()
 
 ~FxTransactionedList ()
 
VOID LockForEnum (__in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
VOID UnlockFromEnum (__in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
NTSTATUS Add (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTransactionedEntry *Entry)
 
VOID Remove (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxTransactionedEntry *Entry)
 
_Must_inspect_result_ FxTransactionedEntryGetNextEntry (__in_opt FxTransactionedEntry *Entry)
 
BOOLEAN Deleting (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt MxEvent *DeleteDoneEvent)
 
- Public Member Functions inherited from FxStump
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in POOL_TYPE PoolType)
 
VOID operator delete (__in PVOID pointer)
 
PVOID operator new[] (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
VOID operator delete[] (__in PVOID pointer)
 

Protected Member Functions

virtual VOID AcquireLock (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __out PKIRQL Irql)=0
 
virtual VOID ReleaseLock (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)=0
 
virtual _Must_inspect_result_ NTSTATUS ProcessAdd (__in FxTransactionedEntry *Entry)
 
virtual VOID EntryAdded (__in FxTransactionedEntry *Entry)
 
virtual VOID EntryRemoved (__in FxTransactionedEntry *Entry)
 
virtual BOOLEAN Compare (__in FxTransactionedEntry *Entry, __in PVOID Data)
 
VOID SearchForAndRemove (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID EntryData)
 
_Must_inspect_result_ FxTransactionedEntryGetNextEntryLocked (__in_opt FxTransactionedEntry *Entry)
 
BOOLEAN RemoveLocked (__in FxTransactionedEntry *Entry)
 
VOID ProcessTransactionList (__in PLIST_ENTRY ReleaseHead)
 
VOID ProcessObjectsToRelease (__in PLIST_ENTRY ReleaseHead)
 
- Protected Member Functions inherited from FxStump
 FxStump (VOID)
 

Protected Attributes

LIST_ENTRY m_ListHead
 
LIST_ENTRY m_TransactionHead
 
MxEventm_DeletingDoneEvent
 
ULONG m_ListLockedRecursionCount
 
BOOLEAN m_DeleteOnRemove
 
BOOLEAN m_Deleting
 
UCHAR m_Retries
 

Detailed Description

Definition at line 90 of file fxtransactionedlist.hpp.

Constructor & Destructor Documentation

◆ FxTransactionedList()

FxTransactionedList::FxTransactionedList ( )

◆ ~FxTransactionedList()

FxTransactionedList::~FxTransactionedList ( )

Definition at line 41 of file fxtransactionedlist.cpp.

42{
45
46 //
47 // If m_DeleteOnRemove is FALSE, there is no need to iterate over any of the
48 // lists to free anything.
49 //
50 if (m_DeleteOnRemove == FALSE) {
53 return;
54 }
55
57
58 while (!IsListEmpty(&m_ListHead)) {
61
63
64 switch (pEntry->m_Transaction) {
66 //
67 // Nothing to do, no pending transaction
68 //
69 break;
70
72 //
73 // Should not have an add transaction and be on the main list at the
74 // same time!
75 //
77 break;
78
80 //
81 // Make sure it is not on the transaction list
82 //
83 RemoveEntryList(&pEntry->m_TransactionLink);
84 InitializeListHead(&pEntry->m_TransactionLink);
85
86 //
87 // When inserted as a remove transaction, we add this reference in
88 // RemoveLocked
89 //
90 pEntry->GetTransactionedObject()->RELEASE(pEntry);
91 break;
92
93 }
94
95 pEntry->GetTransactionedObject()->DeleteObject();
96 }
97
101
102 pEntry = CONTAINING_RECORD(ple, FxTransactionedEntry, m_TransactionLink);
103
104 //
105 // We yanked out all of the removes in the previous loop
106 //
107 ASSERT(pEntry->m_Transaction == FxTransactionActionAdd);
108
109 //
110 // Delete the object since this list owns it.
111 //
112 pEntry->GetTransactionedObject()->DeleteObject();
113 }
114}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964
PSINGLE_LIST_ENTRY ple
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
@ FxTransactionActionNothing
@ FxTransactionActionAdd
@ FxTransactionActionRemove
#define ASSERT(a)
Definition: mode.c:44
static FxTransactionedEntry * _FromEntry(__in PLIST_ENTRY Entry)
Definition: typedefs.h:120
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Member Function Documentation

◆ AcquireLock()

virtual VOID FxTransactionedList::AcquireLock ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__out PKIRQL  Irql 
)
protectedpure virtual

◆ Add()

_Must_inspect_result_ NTSTATUS FxTransactionedList::Add ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in FxTransactionedEntry Entry 
)

Definition at line 263 of file fxtransactionedlist.cpp.

267{
269 KIRQL irql;
270
271 AcquireLock(FxDriverGlobals, &irql);
272
273 if (m_Deleting) {
275 }
276 else {
278 }
279
280 if (NT_SUCCESS(status)) {
282 //
283 // We can insert the entry now, do so
284 //
285 InsertTailList(&m_ListHead, &Entry->m_ListLink);
286
288 }
289 else {
290 //
291 // List is locked, queue a transaction
292 //
293 Entry->m_Transaction = FxTransactionActionAdd;
294 InsertTailList(&m_TransactionHead, &Entry->m_TransactionLink);
295 }
296 }
297
298 ReleaseLock(FxDriverGlobals, irql);
299
300 return status;
301}
LONG NTSTATUS
Definition: precomp.h:26
virtual _Must_inspect_result_ NTSTATUS ProcessAdd(__in FxTransactionedEntry *Entry)
virtual VOID EntryAdded(__in FxTransactionedEntry *Entry)
virtual VOID ReleaseLock(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)=0
virtual VOID AcquireLock(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __out PKIRQL Irql)=0
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KIRQL irql
Definition: wave.h:1
#define InsertTailList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
base of all file and directory entries
Definition: entries.h:83
Definition: ps.c:97
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178

Referenced by FxRelatedDeviceList::Add(), FxPkgPnp::AddChildList(), FxPkgPnp::AddDmaEnabler(), and FxDevice::AddIoTarget().

◆ Compare()

virtual BOOLEAN FxTransactionedList::Compare ( __in FxTransactionedEntry Entry,
__in PVOID  Data 
)
inlineprotectedvirtual

Reimplemented in FxRelatedDeviceList.

Definition at line 177 of file fxtransactionedlist.hpp.

181 {
184
185 return TRUE;
186 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

Referenced by SearchForAndRemove().

◆ Deleting()

BOOLEAN FxTransactionedList::Deleting ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in_opt MxEvent DeleteDoneEvent 
)

Definition at line 238 of file fxtransactionedlist.cpp.

242{
243 KIRQL irql;
245
246 result = TRUE;
247
248 AcquireLock(FxDriverGlobals, &irql);
250
252 m_DeletingDoneEvent = DeleteDoneEvent;
253 result = FALSE;
254 }
255
256 ReleaseLock(FxDriverGlobals, irql);
257
258 return result;
259}
unsigned char BOOLEAN
GLuint64EXT * result
Definition: glext.h:11304

◆ EntryAdded()

virtual VOID FxTransactionedList::EntryAdded ( __in FxTransactionedEntry Entry)
inlineprotectedvirtual

Definition at line 159 of file fxtransactionedlist.hpp.

162 {
164 }

Referenced by Add(), and ProcessTransactionList().

◆ EntryRemoved()

virtual VOID FxTransactionedList::EntryRemoved ( __in FxTransactionedEntry Entry)
inlineprotectedvirtual

Reimplemented in FxRelatedDeviceList.

Definition at line 168 of file fxtransactionedlist.hpp.

171 {
173 }

Referenced by ProcessTransactionList(), and RemoveLocked().

◆ GetNextEntry()

◆ GetNextEntryLocked()

_Must_inspect_result_ FxTransactionedEntry * FxTransactionedList::GetNextEntryLocked ( __in_opt FxTransactionedEntry Entry)
protected

Definition at line 458 of file fxtransactionedlist.cpp.

474{
476
477 if (Entry == NULL) {
479 }
480 else {
481 ple = Entry->m_ListLink.Flink;
482 }
483
484 //
485 // Find the next entry which does not have a pending transaction on it
486 //
487 for ( ; ple != &m_ListHead; ple = ple->Flink) {
489
492 return pNext;
493 }
494 }
495
496 //
497 // Reached the end of the list
498 //
499 return NULL;
500}
FxListTransactionAction m_Transaction
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121

Referenced by GetNextEntry(), FxRelatedDeviceList::ProcessAdd(), and SearchForAndRemove().

◆ LockForEnum()

◆ ProcessAdd()

virtual _Must_inspect_result_ NTSTATUS FxTransactionedList::ProcessAdd ( __in FxTransactionedEntry Entry)
inlineprotectedvirtual

Reimplemented in FxRelatedDeviceList.

Definition at line 148 of file fxtransactionedlist.hpp.

151 {
153
154 return STATUS_SUCCESS;
155 }
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by Add().

◆ ProcessObjectsToRelease()

VOID FxTransactionedList::ProcessObjectsToRelease ( __in PLIST_ENTRY  ReleaseHead)
protected

Definition at line 209 of file fxtransactionedlist.cpp.

212{
215
216 while (!IsListEmpty(ReleaseHead)) {
217 ple = RemoveHeadList(ReleaseHead);
219
220 pEntry = CONTAINING_RECORD(ple, FxTransactionedEntry, m_TransactionLink);
221
222 //
223 // We always release our reference we took when we post the change
224 // to the list
225 //
226 pEntry->GetTransactionedObject()->RELEASE(pEntry);
227
228 //
229 // 2ndary release if the list is set to do this
230 //
231 if (m_DeleteOnRemove) {
232 pEntry->GetTransactionedObject()->DeleteObject();
233 }
234 }
235}

Referenced by UnlockFromEnum().

◆ ProcessTransactionList()

VOID FxTransactionedList::ProcessTransactionList ( __in PLIST_ENTRY  ReleaseHead)
protected

Definition at line 157 of file fxtransactionedlist.cpp.

160{
163
164 //
165 // If there are other iterators, do not process transactions until they are
166 // done.
167 //
169 return;
170 }
171
172 while (!IsListEmpty(&m_TransactionHead)) {
175
176 pEntry = CONTAINING_RECORD(ple, FxTransactionedEntry, m_TransactionLink);
177
178 ASSERT(pEntry->m_Transaction != FxTransactionActionNothing);
179
180 if (pEntry->m_Transaction == FxTransactionActionAdd) {
181 //
182 // Add to the main list
183 //
184 InsertTailList(&m_ListHead, &pEntry->m_ListLink);
185
186 //
187 // Virtual notification of addition
188 //
190 }
191 else if (pEntry->m_Transaction == FxTransactionActionRemove) {
192 //
193 // Remove it from the main list and move it to a free list
194 //
195 RemoveEntryList(&pEntry->m_ListLink);
196 InsertTailList(ReleaseHead, &pEntry->m_TransactionLink);
197
198 //
199 // Virtual notification of removal
200 //
202 }
203
204 pEntry->m_Transaction = FxTransactionActionNothing;
205 }
206}
virtual VOID EntryRemoved(__in FxTransactionedEntry *Entry)

Referenced by UnlockFromEnum().

◆ ReleaseLock()

virtual VOID FxTransactionedList::ReleaseLock ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in KIRQL  Irql 
)
protectedpure virtual

◆ Remove()

VOID FxTransactionedList::Remove ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in FxTransactionedEntry Entry 
)

Definition at line 364 of file fxtransactionedlist.cpp.

368{
369 BOOLEAN removed;
370 KIRQL irql;
371
372 AcquireLock(FxDriverGlobals, &irql);
373 removed = RemoveLocked(Entry);
374 ReleaseLock(FxDriverGlobals,irql);
375
376 if (removed && m_DeleteOnRemove) {
377 Entry->GetTransactionedObject()->DeleteObject();
378 }
379}
BOOLEAN RemoveLocked(__in FxTransactionedEntry *Entry)

Referenced by FxPkgPnp::RemoveChildList(), FxPkgPnp::RemoveDmaEnabler(), and FxDevice::RemoveIoTarget().

◆ RemoveLocked()

BOOLEAN FxTransactionedList::RemoveLocked ( __in FxTransactionedEntry Entry)
protected

Definition at line 382 of file fxtransactionedlist.cpp.

385{
386 BOOLEAN removed;
387
388 removed = FALSE;
389
390 if (Entry->m_Transaction == FxTransactionActionAdd) {
391 //
392 // Not yet added to the list proper, remove it from the transaction list
393 //
394 removed = TRUE;
395 RemoveEntryList(&Entry->m_TransactionLink);
396 InitializeListHead(&Entry->m_TransactionLink);
397
398 Entry->m_Transaction = FxTransactionActionNothing;
399 }
400 else {
401 ASSERT(!IsListEmpty(&Entry->m_ListLink));
402
404 //
405 // List is not locked, remove it now
406 //
407 RemoveEntryList(&Entry->m_ListLink);
408 InitializeListHead(&Entry->m_ListLink);
409
410 //
411 // Virtual notification
412 //
414
415 removed = TRUE;
416 }
417 else {
418 //
419 // List is locked for enumeration, queue a transaction
420 //
421 Entry->m_Transaction = FxTransactionActionRemove;
422 InsertTailList(&m_TransactionHead, &Entry->m_TransactionLink);
423 Entry->GetTransactionedObject()->ADDREF(Entry);
424 }
425 }
426
427 return removed;
428}

Referenced by Remove(), and SearchForAndRemove().

◆ SearchForAndRemove()

VOID FxTransactionedList::SearchForAndRemove ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PVOID  EntryData 
)
protected

Definition at line 304 of file fxtransactionedlist.cpp.

308{
309 KIRQL irql;
312 BOOLEAN removed;
313
314 removed = FALSE;
315
316 AcquireLock(FxDriverGlobals, &irql);
317
320 ple = ple->Flink) {
321
322 pEntry = CONTAINING_RECORD(ple, FxTransactionedEntry, m_TransactionLink);
323
324 if (Compare(pEntry, EntryData)) {
325 if (pEntry->GetTransactionAction() == FxTransactionActionAdd) {
326 RemoveEntryList(&pEntry->m_TransactionLink);
327 InitializeListHead(&pEntry->m_TransactionLink);
328
329 removed = TRUE;
330 }
331 else {
332 //
333 // Already being removed, just return
334 //
335 ASSERT(pEntry->GetTransactionAction() ==
337 }
338
339 goto Done;
340 }
341 }
342
343 //
344 // Walk the committed list
345 //
346 pEntry = NULL;
347
348 while ((pEntry = GetNextEntryLocked(pEntry)) != NULL) {
349 if (Compare(pEntry, EntryData)) {
350 removed = RemoveLocked(pEntry);
351 break;
352 }
353 }
354
355Done:
356 ReleaseLock(FxDriverGlobals, irql);
357
358 if (removed && m_DeleteOnRemove) {
359 pEntry->GetTransactionedObject()->DeleteObject();
360 }
361}
virtual BOOLEAN Compare(__in FxTransactionedEntry *Entry, __in PVOID Data)

Referenced by FxRelatedDeviceList::Remove().

◆ UnlockFromEnum()

VOID FxTransactionedList::UnlockFromEnum ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals)

Definition at line 129 of file fxtransactionedlist.cpp.

132{
133 LIST_ENTRY releaseHead;
134 KIRQL irql;
135 MxEvent* event;
136
137 InitializeListHead(&releaseHead);
138 event = NULL;
139 AcquireLock(FxDriverGlobals, &irql);
141 ProcessTransactionList(&releaseHead);
142
144 event = m_DeletingDoneEvent;
146 }
147 ReleaseLock(FxDriverGlobals, irql);
148
149 ProcessObjectsToRelease(&releaseHead);
150
151 if (event != NULL) {
152 event->Set();
153 }
154}
VOID ProcessObjectsToRelease(__in PLIST_ENTRY ReleaseHead)
VOID ProcessTransactionList(__in PLIST_ENTRY ReleaseHead)
struct _cl_event * event
Definition: glext.h:7739

Referenced by FxPkgPnp::ChildListNotifyRemove(), FxPkgPnp::NotifyResourceobjectsToReleaseResources(), FxPkgPnp::PnpEventSurpriseRemovePendingOverload(), FxPkgPnp::PowerDmaEnableAndScan(), FxPkgPnp::PowerPolicyDisarmWakeFromSx(), FxPkgPnp::PowerPolicyPostParentToD0ToChildren(), FxDevice::SetFilterIoType(), and FxRelatedDeviceList::UnlockFromEnum().

Member Data Documentation

◆ m_DeleteOnRemove

◆ m_Deleting

BOOLEAN FxTransactionedList::m_Deleting
protected

◆ m_DeletingDoneEvent

MxEvent* FxTransactionedList::m_DeletingDoneEvent
protected

Definition at line 220 of file fxtransactionedlist.hpp.

Referenced by Deleting(), FxTransactionedList(), and UnlockFromEnum().

◆ m_ListHead

LIST_ENTRY FxTransactionedList::m_ListHead
protected

◆ m_ListLockedRecursionCount

ULONG FxTransactionedList::m_ListLockedRecursionCount
protected

◆ m_Retries

UCHAR FxTransactionedList::m_Retries
protected

◆ m_TransactionHead


The documentation for this class was generated from the following files: