ReactOS  0.4.15-dev-3303-g1ade494
fxeventqueue.hpp
Go to the documentation of this file.
1 //
2 // Copyright (C) Microsoft. All rights reserved.
3 //
4 #ifndef _FXEVENTQUEUE_H_
5 #define _FXEVENTQUEUE_H_
6 
9  VOID
10  )
11  {
12  m_Event = NULL;
16  }
17 
18  BOOLEAN
20  VOID
21  )
22  {
23  return ((m_Event != NULL) || m_DeleteObject) ? TRUE : FALSE;
24  }
25 
26  VOID
27  Evaluate(
28  __inout FxPkgPnp* PkgPnp
29  );
30 
35 };
36 
37 typedef
38 VOID
40  __in FxPkgPnp* PkgPnp,
43  );
44 
49 };
50 
51 struct FxEventQueue : public FxStump {
53  __in UCHAR QueueDepth
54  );
55 
57  NTSTATUS
58  Initialize(
60  );
61 
65  VOID
66  Lock(
68  PKIRQL Irql
69  )
70  {
71  m_QueueLock.Acquire(Irql);
72  }
73 
76  VOID
77  Unlock(
79  KIRQL Irql
80  )
81  {
82  m_QueueLock.Release(Irql);
83  }
84 
85  BOOLEAN
87  VOID
88  )
89  {
91  }
92 
93  BOOLEAN
95  VOID
96  )
97  {
98  return m_QueueHead == m_QueueTail;
99  }
100 
101  VOID
103  VOID
104  )
105  {
107  }
108 
109  UCHAR
111  VOID
112  )
113  {
114  return m_QueueHead;
115  }
116 
117  UCHAR
119  VOID
120  )
121  {
123  return m_QueueHead;
124  }
125 
126  UCHAR
128  VOID
129  )
130  {
131  UCHAR index;
132 
133  // Save the index which is the current tail
134  index = m_QueueTail;
135 
136  // goto next slot
138 
139  // return the old tail as the slot to insert at
140  return index;
141  }
142 
143  UCHAR
145  VOID
146  )
147  {
148  UCHAR cur;
149 
152 
153  return cur;
154  }
155 
156  BOOLEAN
158  VOID
159  )
160  {
162  }
163 
164  VOID
167  )
168  {
169  if (IsIdleLocked()) {
172  Info->m_DeleteObject = TRUE;
173  }
174 
175  if (IsClosedLocked()) {
176  Info->m_Event = m_WorkItemFinished;
178  }
179  }
180  }
181 
182  BOOLEAN
183  SetFinished(
185  );
186 
187  VOID
189  VOID
190  );
191 
192 protected:
193  VOID
194  Configure(
195  __in FxPkgPnp* Pnp,
198  );
199 
200  BOOLEAN
202  VOID
203  );
204 
205  VOID
207  VOID
208  );
209 
210  BOOLEAN
212  VOID
213  )
214  {
215  //
216  // We are idle if there is no work item queued, no work item running,
217  // and there are no events in the queue. Since m_WorkItemQueued is
218  // cleared before we enter the state machine, we must also track the
219  // number of work items running.
220  //
223  IsEmpty()) {
224  return TRUE;
225  }
226  else {
227  return FALSE;
228  }
229  }
230 
231 protected:
232  // index into the beginning of the circular event ring buffer
234 
235  // index into the end of the circular event ring buffer
237 
238  // circular event ring buffer size
240 
242 
244 
245  //
246  // Context that is passed back to the the state machine as
247  // part of the event worker
248  //
250 
251  //
252  // Lock for the queue
253  //
255 
256 public:
258 
259 protected:
261 
262  //
263  // Guarded by m_QueueLock. Will be set to a valid pointer value when pnp
264  // wants to remove the device and we want to synchronize against the work
265  // item running.
266  //
268 
269  //
270  //
271  union {
272  //
273  // See FxEventQueueFlags for values
274  //
276 
277  struct {
282  };
283 
284  //
285  // Count of times the work item is running. Since m_WorkItemQueued is
286  // cleared before we enter the state machine, we must also track the
287  // number of instances to make sure we know when we are idle or not.
288  //
290 };
291 
294  __in UCHAR QueueDepth
295  );
296 
298 
300  NTSTATUS
301  Init(
302  __inout FxPkgPnp* Pnp,
304  __in PVOID WorkerContext = NULL
305  );
306 
307  VOID
309  VOID
310  )
311  {
312  if (QueueToThreadWorker()) {
313  QueueWorkItem();
314  }
315  }
316 
317 protected:
318  VOID
320  VOID
321  );
322 
323  static
326 
328 };
329 
330 //
331 // struct that encapsulates posting a work item to the dedicated power thread
332 // or work item depending on the power pagable status of the stack.
333 //
336  __in UCHAR QueueDepth
337  );
338 
340  VOID
341  );
342 
344  NTSTATUS
345  Init(
346  __inout FxPkgPnp* Pnp,
348  __in PVOID WorkerContext = NULL
349  );
350 
351  VOID
353  VOID
354  )
355  {
356  if (QueueToThreadWorker()) {
357  QueueWorkItem();
358  }
359  }
360 
361 protected:
362  static
363  WORKER_THREAD_ROUTINE
365 
366  static
369 
370  VOID
372  VOID
373  );
374 
376 
377  // work item used to queue to the thread
379 };
380 
381 #endif // _FXEVENTQUEUE_H_
FxCREvent * m_Event
UCHAR GetHead(VOID)
static MX_WORKITEM_ROUTINE _WorkItemCallback
GLint x0
Definition: linetemp.h:95
MxLock m_QueueLock
#define TRUE
Definition: types.h:120
#define __drv_restoresIRQL
Definition: driverspecs.h:321
_Must_inspect_result_ _In_ PFLT_CALLBACK_DATA _In_ PFLT_DEFERRED_IO_WORKITEM_ROUTINE WorkerRoutine
Definition: fltkernel.h:1976
LONG NTSTATUS
Definition: precomp.h:26
UCHAR WorkItemQueued
FxCREvent * m_WorkItemFinished
#define __drv_maxIRQL(irql)
Definition: driverspecs.h:290
IO_WORKITEM_ROUTINE MX_WORKITEM_ROUTINE
Definition: mxworkitemkm.h:26
DriverGlobals
UCHAR IncrementHistoryIndex(VOID)
FxThreadedEventQueue(__in UCHAR QueueDepth)
Definition: eventqueue.cpp:352
_Must_inspect_result_ NTSTATUS Init(__inout FxPkgPnp *Pnp, __in PFN_PNP_EVENT_WORKER WorkerRoutine, __in PVOID WorkerContext=NULL)
Definition: eventqueue.cpp:370
_Out_ PKIRQL Irql
Definition: csq.h:179
static WORKER_THREAD_ROUTINE _WorkerThreadRoutine
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
UCHAR KIRQL
Definition: env_spec_w32.h:591
BOOLEAN IsFull(VOID)
VOID IncrementHead(VOID)
struct FxEventQueue::@4515::@4517 m_QueueFlagsByName
_Must_inspect_result_ NTSTATUS Initialize(__in PFX_DRIVER_GLOBALS DriverGlobals)
Definition: eventqueue.cpp:55
#define FALSE
Definition: types.h:117
VOID SetDelayedDeletion(VOID)
Definition: eventqueue.cpp:135
FxEventQueue(__in UCHAR QueueDepth)
Definition: eventqueue.cpp:36
BOOLEAN m_SetRemovedEvent
VOID(* PFN_PNP_EVENT_WORKER)(__in FxPkgPnp *PkgPnp, __in FxPostProcessInfo *Info, __in PVOID Context)
VOID EventQueueWorker(VOID)
Definition: eventqueue.cpp:229
#define __out
Definition: dbghelp.h:62
unsigned char BOOLEAN
IWudfIrp * MdIrp
Definition: mxum.h:103
PVOID m_EventWorkerContext
GLuint index
Definition: glext.h:6031
FxPkgPnp * m_PkgPnp
PFN_PNP_EVENT_WORKER m_EventWorker
UCHAR InsertAtTail(VOID)
FxWorkItemEventQueue(__in UCHAR QueueDepth)
Definition: eventqueue.cpp:308
#define __drv_requiresIRQL(irql)
Definition: driverspecs.h:320
BOOLEAN SomethingToDo(VOID)
UCHAR InsertAtHead(VOID)
UCHAR m_WorkItemRunningCount
_Must_inspect_result_ this m_Lock __drv_setsIRQL(APC_LEVEL)) _When_(return
_Releases_lock_(this->m_QueueLock) __drv_requiresIRQL(DISPATCH_LEVEL) VOID Unlock(__in __drv_restoresIRQL KIRQL Irql)
VOID QueueWorkItem(VOID)
Definition: eventqueue.cpp:400
unsigned char UCHAR
Definition: xmlstorage.h:181
#define index(s, c)
Definition: various.h:29
#define VOID
Definition: acefi.h:82
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#define __drv_deref(annotes)
Definition: driverspecs.h:264
#define __inout
Definition: dbghelp.h:50
#define _Must_inspect_result_
Definition: ms_sal.h:558
BOOLEAN IsClosedLocked(VOID)
Definition: mxlock.h:101
FxCollectionEntry * cur
VOID GetFinishedState(__inout FxPostProcessInfo *Info)
BOOLEAN QueueToThreadWorker(VOID)
Definition: eventqueue.cpp:154
BOOLEAN IsIdleLocked(VOID)
static MX_WORKITEM_ROUTINE _WorkItemCallback
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
_Acquires_lock_(this->m_QueueLock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL Irql)
VOID Evaluate(__inout FxPkgPnp *PkgPnp)
Definition: fxpkgpnp.hpp:4566
WORK_QUEUE_ITEM m_EventWorkQueueItem
BOOLEAN IsEmpty(VOID)
_Must_inspect_result_ NTSTATUS Init(__inout FxPkgPnp *Pnp, __in PFN_PNP_EVENT_WORKER WorkerRoutine, __in PVOID WorkerContext=NULL)
Definition: eventqueue.cpp:321
#define __drv_savesIRQL
Definition: driverspecs.h:325
#define NULL
Definition: types.h:112
UCHAR m_HistoryIndex
struct tagContext Context
Definition: acpixf.h:1034
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
VOID QueueWorkItem(VOID)
FxEventQueueFlags
BOOLEAN SetFinished(__in FxCREvent *Event)
Definition: eventqueue.cpp:91
#define __in
Definition: dbghelp.h:35
FxWaitLockInternal m_StateMachineLock
VOID Configure(__in FxPkgPnp *Pnp, __in PFN_PNP_EVENT_WORKER WorkerRoutine, __in PVOID Context)
Definition: eventqueue.cpp:77