ReactOS  0.4.15-dev-2700-g4b4ffa9
FxSystemWorkItem Class Reference

#include <fxsystemworkitem.hpp>

Inheritance diagram for FxSystemWorkItem:
Collaboration diagram for FxSystemWorkItem:

Public Member Functions

virtual ~FxSystemWorkItem ()
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__inout FxQueryInterfaceParams *Params)
 
__inline MdWorkItem GetWorkItemPtr (VOID)
 
__inline BOOLEAN Enqueue (__in PFN_WDF_SYSTEMWORKITEM CallbackFunc, __in PVOID Parameter)
 
__inline BOOLEAN TryToEnqueue (__in PFN_WDF_SYSTEMWORKITEM CallbackFunc, __in PVOID Parameter)
 
VOID WaitForExit (VOID)
 
__inline VOID IncrementWorkItemQueued ()
 
__inline VOID DecrementWorkItemQueued ()
 
__inline VOID ReleaseWorkItemQueuedCountAndWait ()
 
 DECLARE_INTERNAL_NEW_OPERATOR ()
 
- Public Member Functions inherited from FxNonPagedObject
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
virtual ~FxNonPagedObject (VOID)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL PreviousIrql)
 
 _Releases_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID Unlock(__in __drv_restoresIRQL KIRQL PreviousIrql)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) VOID LockAtDispatch(VOID)
 
 _Requires_lock_held_ (this->m_NPLock.m_Lock) _Releases_lock_(this -> m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID UnlockFromDispatch(VOID)
 
- Public Member Functions inherited from FxObject
PVOID GetCOMWrapper ()
 
void SetCOMWrapper (__drv_aliasesMem PVOID Wrapper)
 
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
virtual ~FxObject (VOID)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType Type)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize=0)
 
VOID operator delete (__in PVOID Memory)
 
VOID SetNoContextHeader (VOID)
 
PVOID __inline GetObjectHandle (VOID)
 
__inline FxContextHeaderGetContextHeader (VOID)
 
__inline PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)
 
WDFTYPE GetType (VOID)
 
USHORT GetObjectSize (VOID)
 
LONG GetRefCnt (VOID)
 
FxTagTrackerGetTagTracker (VOID)
 
CfxDeviceGetDevice (VOID)
 
CfxDeviceBaseGetDeviceBase (VOID)
 
VOID SetDeviceBase (__in CfxDeviceBase *DeviceBase)
 
__inline VOID CallCleanup (VOID)
 
ULONG __inline AddRef (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG Release (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG AddRefOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG ReleaseOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
VOID MarkTraceState (VOID)
 
BOOLEAN __inline IsTraceState (VOID)
 
VOID __inline TraceDroppedEvent (__in FxObjectDroppedEvent Event)
 
VOID MarkPassiveDispose (__in FxObjectLockState State=ObjectLock)
 
VOID MarkPassiveCallbacks (__in FxObjectLockState State=ObjectLock)
 
VOID MarkForceDisposeThread (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsPassiveCallbacks (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsPassiveDispose (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsForceDisposeThread (__in BOOLEAN AcquireLock=TRUE)
 
VOID MarkCommitted (VOID)
 
BOOLEAN IsCommitted (VOID)
 
VOID MarkDisposeOverride (__in FxObjectLockState State=ObjectLock)
 
VOID MarkNoDeleteDDI (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsNoDeleteDDI (VOID)
 
_Must_inspect_result_ NTSTATUS Commit (__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
 
VOID DeleteFromFailedCreate (VOID)
 
VOID ClearEvtCallbacks (VOID)
 
BOOLEAN EarlyDispose (VOID)
 
virtual VOID DeleteObject (VOID)
 
_Must_inspect_result_ NTSTATUS AssignParentObject (__in FxObject *ParentObject)
 
_Must_inspect_result_ NTSTATUS AddContext (__in FxContextHeader *Header, __in PVOID *Context, __in PWDF_OBJECT_ATTRIBUTES Attributes)
 
_Must_inspect_result_ NTSTATUS RemoveParentAssignment (VOID)
 
_Must_inspect_result_ FxObjectGetParentObjectReferenced (__in PVOID Tag)
 
BOOLEAN IsDisposed (VOID)
 

Static Public Member Functions

static _Must_inspect_result_ NTSTATUS _Create (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID WdmObject, __out FxSystemWorkItem **pObject)
 
- Static Public Member Functions inherited from FxObject
static FxObject_FromDisposeEntry (__in PSINGLE_LIST_ENTRY Entry)
 
static FxObject_GetObjectFromHandle (__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
 
static PVOID __inline _ToHandle (__in FxObject *Object)
 
static VOID __inline _ReferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static VOID __inline _DereferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static PVOID _GetDebugBase (__in FxObject *Object)
 
static PFX_POOL_HEADER _CleanupPointer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Object)
 
static _Must_inspect_result_ NTSTATUS _GetEffectiveLock (__in FxObject *Object, __in_opt IFxHasCallbacks *Callbacks, __in BOOLEAN AutomaticLocking, __in BOOLEAN PassiveCallbacks, __out FxCallbackLock **CallbackLock, __out_opt FxObject **CallbackLockObject)
 
static _Must_inspect_result_ NTSTATUS _ObjectQuery (_In_ FxObject *Object, _In_ CONST GUID *Guid, _In_ ULONG QueryBufferLength, _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
 

Private Member Functions

 FxSystemWorkItem (__in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS Initialize (__in PVOID WdmObject)
 
VOID WorkItemHandler ()
 
BOOLEAN EnqueueWorker (__in PFN_WDF_SYSTEMWORKITEM Func, __in PVOID Parameter, __in BOOLEAN AssertIfAlreadyQueued)
 

Private Attributes

BOOLEAN m_RunningDown
 
BOOLEAN m_Enqueued
 
MxWorkItem m_WorkItem
 
PFN_WDF_SYSTEMWORKITEM m_Callback
 
PVOID m_CallbackArg
 
FxCREvent m_WorkItemCompleted
 
ULONG m_WorkItemRunningCount
 
LONG m_OutStandingWorkItem
 
FxCREvent m_RemoveEvent
 

Static Private Attributes

static MX_WORKITEM_ROUTINE _WorkItemThunk
 

Additional Inherited Members

- Protected Member Functions inherited from FxObject
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
FxObjectDebugExtensionGetDebugExtension (VOID)
 
BOOLEAN IsDebug (VOID)
 
VOID AllocateTagTracker (__in WDFTYPE Type)
 
virtual VOID SelfDestruct (VOID)
 
PVOID __inline GetObjectHandleUnchecked (VOID)
 
VOID __inline DestroyChildren (VOID)
 
VOID DeleteEarlyDisposedObject (VOID)
 
- Static Protected Member Functions inherited from FxObject
static PVOID _GetBase (__in FxObject *Object)
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Detailed Description

Definition at line 48 of file fxsystemworkitem.hpp.

Constructor & Destructor Documentation

◆ ~FxSystemWorkItem()

FxSystemWorkItem::~FxSystemWorkItem ( )
virtual

Definition at line 81 of file fxsystemworkitem.cpp.

82 {
83  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
84 
85  //
86  // If this hits, it's because someone destroyed the WORKITEM by
87  // removing too many references by mistake without calling WdfObjectDelete
88  //
89  if( !m_RunningDown && (m_WorkItem.GetWorkItem() != NULL)) {
91  "WorkItem destroyed without calling "
92  "FxSystemWorkItem::Delete, or by Framework "
93  "processing DeviceRemove. "
94  "Possible reference count problem?");
95  FxVerifierDbgBreakPoint(FxDriverGlobals);
96  }
97 
98  // Free the workitem
99  if( m_WorkItem.GetWorkItem() != NULL ) {
100  m_WorkItem.Free();
101  }
102 
103  ASSERT(m_Enqueued == FALSE);
105 
106  return;
107 }
__inline MdWorkItem GetWorkItem()
Definition: mxworkitemkm.h:73
#define FALSE
Definition: types.h:117
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define ASSERT(a)
Definition: mode.c:44
static const WCHAR L[]
Definition: oid.c:1250
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
__inline VOID Free()
Definition: mxworkitemkm.h:90
FxVerifierDbgBreakPoint(pFxDriverGlobals)

◆ FxSystemWorkItem()

FxSystemWorkItem::FxSystemWorkItem ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals)
private

Definition at line 66 of file fxsystemworkitem.cpp.

68  :
69  FxNonPagedObject(FX_TYPE_SYSTEMWORKITEM, 0, FxDriverGlobals),
72 {
74  m_Enqueued = FALSE;
75  m_Callback = NULL;
79 }
PFN_WDF_SYSTEMWORKITEM m_Callback
FxNonPagedObject(__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
#define TRUE
Definition: types.h:120
FxCREvent m_WorkItemCompleted
#define FALSE
Definition: types.h:117
#define NULL
Definition: types.h:112

Referenced by _Create().

Member Function Documentation

◆ _Create()

_Must_inspect_result_ NTSTATUS FxSystemWorkItem::_Create ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PVOID  WdmObject,
__out FxSystemWorkItem **  pObject 
)
static

Definition at line 41 of file fxsystemworkitem.cpp.

46 {
48  FxSystemWorkItem* wi;
49 
50  wi = new(FxDriverGlobals) FxSystemWorkItem(FxDriverGlobals);
51  if (wi == NULL) {
53  }
54 
55  status = wi->Initialize(WdmObject);
56  if (!NT_SUCCESS(status)) {
57  wi->Release();
58  return status;
59  }
60 
61  *pObject = wi;
62 
63  return status;
64 }
FxObject * pObject
virtual ULONG Release(__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
Definition: fxobject.hpp:853
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
FxSystemWorkItem(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define NULL
Definition: types.h:112
_Must_inspect_result_ NTSTATUS Initialize(__in PVOID WdmObject)
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by FxUsbPipeContinuousReader::Config(), FxDisposeList::Initialize(), FxTimer::Initialize(), FxIoQueue::Initialize(), and FxInterrupt::InitializeWorker().

◆ DECLARE_INTERNAL_NEW_OPERATOR()

FxSystemWorkItem::DECLARE_INTERNAL_NEW_OPERATOR ( )

◆ DecrementWorkItemQueued()

__inline VOID FxSystemWorkItem::DecrementWorkItemQueued ( )
inline

Definition at line 185 of file fxsystemworkitem.hpp.

187  {
188  LONG result;
189 
191 
193 
194  if (result == 0) {
195  m_RemoveEvent.Set();
196  }
197  }
GLuint64EXT * result
Definition: glext.h:11304
VOID Set(VOID)
Definition: fxwaitlock.hpp:144
long LONG
Definition: pedump.c:60
#define ASSERT(a)
Definition: mode.c:44
#define InterlockedDecrement
Definition: armddk.h:52

Referenced by ReleaseWorkItemQueuedCountAndWait().

◆ Dispose()

BOOLEAN FxSystemWorkItem::Dispose ( VOID  )
privatevirtual

Reimplemented from FxObject.

Definition at line 324 of file fxsystemworkitem.cpp.

326 {
327  KIRQL irql;
328 
330 
331  Lock(&irql);
332 
334 
336 
337  Unlock(irql);
338 
340 
341  return TRUE;
342 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
#define TRUE
Definition: types.h:120
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define ASSERT(a)
Definition: mode.c:44
static __inline KIRQL MxGetCurrentIrql()
Definition: mxgeneralkm.h:86
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
__inline VOID ReleaseWorkItemQueuedCountAndWait()

◆ Enqueue()

__inline BOOLEAN FxSystemWorkItem::Enqueue ( __in PFN_WDF_SYSTEMWORKITEM  CallbackFunc,
__in PVOID  Parameter 
)
inline

Definition at line 150 of file fxsystemworkitem.hpp.

154  {
155  return EnqueueWorker(CallbackFunc, Parameter, TRUE);
156  }
#define TRUE
Definition: types.h:120
_In_ PVOID Parameter
Definition: ldrtypes.h:241
BOOLEAN EnqueueWorker(__in PFN_WDF_SYSTEMWORKITEM Func, __in PVOID Parameter, __in BOOLEAN AssertIfAlreadyQueued)

Referenced by FxIoQueue::CanThreadDispatchEventsLocked(), FxIoQueue::DeferredDispatchRequestsFromWorkerThread(), and FxUsbPipeContinuousReader::QueueWorkItemLocked().

◆ EnqueueWorker()

BOOLEAN FxSystemWorkItem::EnqueueWorker ( __in PFN_WDF_SYSTEMWORKITEM  Func,
__in PVOID  Parameter,
__in BOOLEAN  AssertIfAlreadyQueued 
)
private

Definition at line 159 of file fxsystemworkitem.cpp.

187 {
189  KIRQL irql;
190 
192 
193  Lock(&irql);
194 
195  if( m_Enqueued ) {
196  if (AssertIfAlreadyQueued) {
198  "WorkItem 0x%p already enqueued IoWorkItem 0x%p",
199  this, m_WorkItem.GetWorkItem());
201  }
202 
203  Unlock(irql);
204  return FALSE;
205  }
206 
207  //
208  // If running down, fail
209  //
210  if( m_RunningDown ) {
212  "WorkItem 0x%p is already deleted", this);
214  Unlock(irql);
215  return FALSE;
216  }
217 
219 
220  m_Callback = Func;
222 
223  m_Enqueued = TRUE;
224 
225  // Add a reference while outstanding
227 
228  Unlock(irql);
229 
231 
232  return TRUE;
233 }
PFN_WDF_SYSTEMWORKITEM m_Callback
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
__inline MdWorkItem GetWorkItem()
Definition: mxworkitemkm.h:73
#define TRUE
Definition: types.h:120
FxCREvent m_WorkItemCompleted
KIRQL irql
Definition: wave.h:1
_In_ PVOID Parameter
Definition: ldrtypes.h:241
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define TRACINGDEVICE
Definition: dbgtrace.h:58
PFX_DRIVER_GLOBALS pFxDriverGlobals
VOID Clear(VOID)
Definition: fxwaitlock.hpp:152
__inline VOID Enqueue(__in PMX_WORKITEM_ROUTINE Callback, __in PVOID Context)
Definition: mxworkitemkm.h:58
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
void(* Func)(int)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
__inline VOID IncrementWorkItemQueued()
static MX_WORKITEM_ROUTINE _WorkItemThunk
FxVerifierDbgBreakPoint(pFxDriverGlobals)

Referenced by Enqueue(), and TryToEnqueue().

◆ GetWorkItemPtr()

__inline MdWorkItem FxSystemWorkItem::GetWorkItemPtr ( VOID  )
inline

Definition at line 141 of file fxsystemworkitem.hpp.

144  {
145  return m_WorkItem.GetWorkItem();
146  }
__inline MdWorkItem GetWorkItem()
Definition: mxworkitemkm.h:73

◆ IncrementWorkItemQueued()

__inline VOID FxSystemWorkItem::IncrementWorkItemQueued ( )
inline

Definition at line 175 of file fxsystemworkitem.hpp.

177  {
179 
181  }
#define ASSERT(a)
Definition: mode.c:44
#define InterlockedIncrement
Definition: armddk.h:53

Referenced by EnqueueWorker().

◆ Initialize()

_Must_inspect_result_ NTSTATUS FxSystemWorkItem::Initialize ( __in PVOID  WdmObject)
private

Definition at line 111 of file fxsystemworkitem.cpp.

114 {
115  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
117 
118  //
119  // Mark this object as passive level to ensure that Dispose() is passive
120  //
122 
124 
125 #if (FX_CORE_MODE == FX_CORE_USER_MODE)
127  if (!NT_SUCCESS(status)) {
129  "Could not initialize m_WorkItemCompleted event "
130  "status %!status!", status);
131  return status;
132  }
133 
135  if(!NT_SUCCESS(status)) {
137  "Could not initialize m_RemoveEvent event "
138  "status %!status!", status);
139  return status;
140  }
141 #endif
142 
143  //
144  // Allocate the PIO_WORKITEM we will re-use
145  //
146  status = m_WorkItem.Allocate((MdDeviceObject) WdmObject);
147  if(!NT_SUCCESS(status)) {
149  "Could not allocate IoWorkItem, insufficient resources");
150  return status;
151  }
152 
154 
155  return STATUS_SUCCESS;
156 }
CHECK_RETURN_IF_USER_MODE NTSTATUS Initialize(__in BOOLEAN InitialState=FALSE)
Definition: fxwaitlock.hpp:51
__inline MdWorkItem GetWorkItem()
Definition: mxworkitemkm.h:73
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
FxCREvent m_WorkItemCompleted
#define FALSE
Definition: types.h:117
VOID MarkDisposeOverride(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1101
_Must_inspect_result_ __inline NTSTATUS Allocate(__in MdDeviceObject DeviceObject, __in_opt PVOID ThreadPoolEnv=NULL)
Definition: mxworkitemkm.h:41
VOID MarkPassiveCallbacks(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:972
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by _Create().

◆ QueryInterface()

virtual _Must_inspect_result_ NTSTATUS FxSystemWorkItem::QueryInterface ( __inout FxQueryInterfaceParams Params)
inlinevirtual

Definition at line 123 of file fxsystemworkitem.hpp.

126  {
127  switch (Params->Type) {
129  *Params->Object = (FxSystemWorkItem*) this;
130  break;
131 
132  default:
133  return FxNonPagedObject::QueryInterface(Params); // __super call
134  }
135 
136  return STATUS_SUCCESS;
137  }
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
Definition: fxobject.cpp:255
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ ReleaseWorkItemQueuedCountAndWait()

__inline VOID FxSystemWorkItem::ReleaseWorkItemQueuedCountAndWait ( )
inline

Definition at line 201 of file fxsystemworkitem.hpp.

203  {
205 
206  //
207  // Drop the bias count to indicate the object is being removed.
208  //
210 
214 
216  }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS EnterCRAndWaitAndLeave(VOID)
Definition: fxwaitlock.hpp:87
__inline VOID DecrementWorkItemQueued()
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by Dispose().

◆ TryToEnqueue()

__inline BOOLEAN FxSystemWorkItem::TryToEnqueue ( __in PFN_WDF_SYSTEMWORKITEM  CallbackFunc,
__in PVOID  Parameter 
)
inline

Definition at line 160 of file fxsystemworkitem.hpp.

164  {
165  return EnqueueWorker(CallbackFunc, Parameter, FALSE);
166  }
_In_ PVOID Parameter
Definition: ldrtypes.h:241
#define FALSE
Definition: types.h:117
BOOLEAN EnqueueWorker(__in PFN_WDF_SYSTEMWORKITEM Func, __in PVOID Parameter, __in BOOLEAN AssertIfAlreadyQueued)

Referenced by FxDisposeList::Add(), and FxInterrupt::QueueWorkItemForIsr().

◆ WaitForExit()

VOID FxSystemWorkItem::WaitForExit ( VOID  )

Definition at line 354 of file fxsystemworkitem.cpp.

356 {
358 
359  //
360  // Wait for current workitem to complete processing
361  //
363 
366 
367  //
368  // This assert is not under a lock, but the code in WorkItemHandler()
369  // clears m_Enqueued under the lock, thus releasing it with a memory
370  // barrier. Since we have ensured above that no one can re-queue a request
371  // due to m_RunningDown, we should not hit this assert unless there
372  // is a code problem with wakeup occuring while an outstanding
373  // workitem is running.
374  //
375  ASSERT(m_Enqueued == FALSE);
376 
377  return;
378 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
FxCREvent m_WorkItemCompleted
#define FALSE
Definition: types.h:117
NTSTATUS EnterCRAndWaitAndLeave(VOID)
Definition: fxwaitlock.hpp:87
Status
Definition: gdiplustypes.h:24
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32

Referenced by FxInterrupt::FlushQueuedWorkitem(), FxTimer::Stop(), FxDisposeList::WaitForEmpty(), and FxUsbPipe::WaitForSentIoToComplete().

◆ WorkItemHandler()

VOID FxSystemWorkItem::WorkItemHandler ( )
private

Definition at line 236 of file fxsystemworkitem.cpp.

237 {
239  PVOID CallbackArg;
240  KIRQL irql;
241 
243 
244  Lock(&irql);
245 
246  m_Enqueued = FALSE;
247 
249  CallbackArg = m_CallbackArg;
250 
251  m_Callback = NULL;
252 
253  //
254  // We should only see this count rise to a small number (like 10 or so).
255  //
257 
259 
260  Unlock(irql);
261 
262  Callback(CallbackArg);
263 
264  Lock(&irql);
265 
267 
268  //
269  // The driver could re-enqueue a new callback from within the
270  // callback handler, which could make m_Enqueued no longer false.
271  //
272  // We only set the event specifying the callback as completed when
273  // we are ensured that no more workitems are enqueued.
274  //
275  if (m_WorkItemRunningCount == 0L && m_Enqueued == FALSE) {
277  }
278 
279  Unlock(irql);
280 
281  return;
282 }
PFN_WDF_SYSTEMWORKITEM m_Callback
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
EVT_SYSTEMWORKITEM * PFN_WDF_SYSTEMWORKITEM
FxCREvent m_WorkItemCompleted
KIRQL irql
Definition: wave.h:1
VOID Set(VOID)
Definition: fxwaitlock.hpp:144
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define ASSERT(a)
Definition: mode.c:44
static const WCHAR L[]
Definition: oid.c:1250
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:456
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define NULL
Definition: types.h:112
FX_TRACK_DRIVER(fxDriverGlobals)
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124

Member Data Documentation

◆ _WorkItemThunk

VOID FxSystemWorkItem::_WorkItemThunk
staticprivate

Definition at line 243 of file fxsystemworkitem.hpp.

Referenced by EnqueueWorker().

◆ m_Callback

PFN_WDF_SYSTEMWORKITEM FxSystemWorkItem::m_Callback
private

Definition at line 68 of file fxsystemworkitem.hpp.

Referenced by EnqueueWorker(), FxSystemWorkItem(), and WorkItemHandler().

◆ m_CallbackArg

PVOID FxSystemWorkItem::m_CallbackArg
private

Definition at line 70 of file fxsystemworkitem.hpp.

Referenced by EnqueueWorker(), FxSystemWorkItem(), and WorkItemHandler().

◆ m_Enqueued

BOOLEAN FxSystemWorkItem::m_Enqueued
private

◆ m_OutStandingWorkItem

LONG FxSystemWorkItem::m_OutStandingWorkItem
private

◆ m_RemoveEvent

FxCREvent FxSystemWorkItem::m_RemoveEvent
private

◆ m_RunningDown

BOOLEAN FxSystemWorkItem::m_RunningDown
private

Definition at line 53 of file fxsystemworkitem.hpp.

Referenced by Dispose(), EnqueueWorker(), FxSystemWorkItem(), and ~FxSystemWorkItem().

◆ m_WorkItem

MxWorkItem FxSystemWorkItem::m_WorkItem
private

Definition at line 63 of file fxsystemworkitem.hpp.

Referenced by EnqueueWorker(), GetWorkItemPtr(), Initialize(), and ~FxSystemWorkItem().

◆ m_WorkItemCompleted

FxCREvent FxSystemWorkItem::m_WorkItemCompleted
private

Definition at line 76 of file fxsystemworkitem.hpp.

Referenced by EnqueueWorker(), Initialize(), WaitForExit(), and WorkItemHandler().

◆ m_WorkItemRunningCount

ULONG FxSystemWorkItem::m_WorkItemRunningCount
private

Definition at line 84 of file fxsystemworkitem.hpp.

Referenced by FxSystemWorkItem(), WorkItemHandler(), and ~FxSystemWorkItem().


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