ReactOS  0.4.15-dev-3187-ge372f2b
fxdisposelist.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxDisposalList.hpp
8 
9 Abstract:
10 
11  This class implements a Disposal list for deferring Dispose
12  processing from dispatch to passive level.
13 
14 Author:
15 
16 
17 
18 
19 
20 
21 Environment:
22 
23  Both kernel and user mode
24 
25 Revision History:
26 
27 
28 --*/
29 
30 #ifndef _FXDISPOSELIST_H_
31 #define _FXDISPOSELIST_H_
32 
33 /*
34  * Some objects can perform dispose/cleanup processing at DISPATCH_LEVEL,
35  * and must defer cleanup processing to PASSIVE_LEVEL.
36  *
37  * This is either due to use of page-able data or code, or a passive
38  * level callback constraint on the object.
39  *
40  * This class supports this by providing a list to enqueue objects on
41  * that need dispose, and an event that may be used by a calling thread
42  * such as the Pnp DeviceRemove thread that must synchronize all object
43  * rundown associated with an FxDevice before returning.
44  *
45  * This is designed to operate in an allocation free manner, and re-uses
46  * an FxObject entry that is not longer in use when an object is in
47  * a deferred dispose state.
48  *
49  */
50 
52 
53 private:
54 
55  //
56  // The List of items to cleanup
57  //
59 
60  //
61  // Pointer to the end of the list so appending does not require traversal
62  // of the entire list
63  //
65 
66  //
67  // This is a pointer to thread object that invoked our workitem
68  // callback. This value will be used to avoid deadlock when we try
69  // to flush the workitem.
70  //
72 
74 
75  //
76  // WDM PDRIVER or PDEVICE_OBJECT for allocating PIO_WORKITEMS
77  //
79 
80 private:
81  static
82  VOID
85  );
86 
87  VOID
89  PKIRQL PreviousIrql
90  );
91 
92  virtual
93  BOOLEAN
94  Dispose(
95  VOID
96  );
97 
98 public:
99 
100  static
101  NTSTATUS
102  _Create(
103  PFX_DRIVER_GLOBALS FxDriverGlobals,
104  PVOID WdmObject,
106  );
107 
109  PFX_DRIVER_GLOBALS FxDriverGlobals
110  );
111 
113  );
114 
115  NTSTATUS
116  Initialize(
117  PVOID wdmObject
118  );
119 
120  //
121  // Add an object to the list.
122  //
123  // The object's m_DisposeListEntry is used and must be initialized
124  //
125  VOID
126  Add(
127  FxObject* object
128  );
129 
130  //
131  // Waits until the list is empty
132  //
133  VOID
134  WaitForEmpty(
135  VOID
136  );
137 
139 };
140 
141 #endif // _FXDISPOSELIST_H_
142 
FxObject * pObject
static VOID _WorkItemThunk(__in PVOID Parameter)
Definition: ntbasedef.h:628
LONG NTSTATUS
Definition: precomp.h:26
SINGLE_LIST_ENTRY m_List
_In_ PVOID Parameter
Definition: ldrtypes.h:241
FxDisposeList(PFX_DRIVER_GLOBALS FxDriverGlobals)
NTSTATUS Initialize(PVOID wdmObject)
FxSystemWorkItem * m_SystemWorkItem
SINGLE_LIST_ENTRY ** m_ListEnd
unsigned char BOOLEAN
virtual BOOLEAN Dispose(VOID)
VOID Add(FxObject *object)
VOID DrainListLocked(PKIRQL PreviousIrql)
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
static NTSTATUS _Create(PFX_DRIVER_GLOBALS FxDriverGlobals, PVOID WdmObject, FxDisposeList **pObject)
DECLARE_INTERNAL_NEW_OPERATOR()
VOID WaitForEmpty(VOID)
MxThread m_WorkItemThread
#define __in
Definition: dbghelp.h:35