1 /*++ 2 3 Copyright (c) Microsoft Corporation 4 5 ModuleName: 6 7 MxWorkItem.h 8 9 Abstract: 10 11 Mode agnostic definition of WorkItem functions 12 13 See MxWorkItemKm.h and MxWorkItemUm.h for mode 14 specific implementations 15 16 Author: 17 18 19 20 Revision History: 21 22 23 24 --*/ 25 26 #pragma once 27 28 class MxWorkItem 29 { 30 31 protected: 32 MdWorkItem m_WorkItem; 33 34 public: 35 36 __inline 37 MxWorkItem( 38 ); 39 40 // 41 // This is used only by the UM implementation 42 // 43 44 #if ((FX_CORE_MODE)==(FX_CORE_USER_MODE)) 45 static 46 VOID 47 CALLBACK 48 _WorkerThunk ( 49 _Inout_ PTP_CALLBACK_INSTANCE Instance, 50 _Inout_opt_ PVOID Parameter, 51 _Inout_ PTP_WAIT Wait, 52 _In_ TP_WAIT_RESULT WaitResult 53 ); 54 55 VOID 56 WaitForCallbacksToComplete( 57 VOID 58 ); 59 60 #endif 61 62 _Must_inspect_result_ 63 __inline 64 NTSTATUS 65 Allocate( 66 __in MdDeviceObject DeviceObject, 67 __in_opt PVOID ThreadPoolEnv = NULL 68 ); 69 70 __inline 71 VOID 72 Enqueue( 73 __in PMX_WORKITEM_ROUTINE Callback, 74 __in PVOID Context 75 ); 76 77 __inline 78 MdWorkItem 79 GetWorkItem( 80 ); 81 82 static 83 __inline 84 VOID 85 _Free( 86 __in MdWorkItem Item 87 ); 88 89 __inline 90 VOID 91 Free( 92 ); 93 94 __inline ~MxWorkItem()95 ~MxWorkItem( 96 ) 97 { 98 } 99 100 }; 101 102 // 103 // MxAutoWorkItem adds value to MxWorkItem by automatically freeing the 104 // associated MdWorkItem when it goes out of scope 105 // 106 struct MxAutoWorkItem : public MxWorkItem { 107 public: 108 MxAutoWorkItemMxAutoWorkItem109 MxAutoWorkItem( 110 ) 111 { 112 } 113 114 __inline 115 ~MxAutoWorkItem( 116 ); 117 }; 118 119