1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7     FxIoQueueCallbacks.h
8 
9 Abstract:
10 
11     This module implements the I/O package queue object callbacks
12 
13 Author:
14 
15 
16 
17 
18 Environment:
19 
20     Both kernel and user mode
21 
22 Revision History:
23 
24 --*/
25 
26 #ifndef _FXREQUESTCALLBACKS_H_
27 #define _FXREQUESTCALLBACKS_H_
28 
29 
30 //
31 // Delegate which contains EvtRequestCancel
32 //
33 class FxRequestCancelCallback : public FxCallback {
34 
35 public:
36     PFN_WDF_REQUEST_CANCEL m_Cancel;
37 
38     FxRequestCancelCallback(
39         VOID
40         )
41     {
42         m_Cancel = NULL;
43     }
44 
45     void
46     InvokeCancel(
47         __in FxCallbackLock* Lock,
48         __in WDFREQUEST Request
49         )
50     {
51         if (m_Cancel != NULL) {
52             PFN_WDF_REQUEST_CANCEL pMethod;
53             KIRQL irql;
54 
55             //
56             // Satisfy W4 warning, even though it is technically not necessary to
57             // assign an initial value.
58             //
59             irql = PASSIVE_LEVEL;
60 
61             if (Lock != NULL) {
62                 Lock->Lock(&irql);
63             }
64 
65             //
66             // Clear the value before invoking the routine since the assignment
67             // is invalidated when the routine is run.
68             //
69             pMethod = m_Cancel;
70             m_Cancel = NULL;
71 
72             pMethod(Request);
73 
74             if (Lock != NULL) {
75                 Lock->Unlock(irql);
76             }
77         }
78     }
79 };
80 
81 //
82 // Delegate which contains EvtRequestCompletion
83 //
84 class FxRequestCompletionCallback : public FxCallback {
85 
86 public:
87     PFN_WDF_REQUEST_COMPLETION_ROUTINE m_Completion;
88 
89     FxRequestCompletionCallback(
90         VOID
91         )
92     {
93         m_Completion = NULL;
94     }
95 };
96 
97 
98 #endif // _FXREQUESTCALLBACKS_H_
99 
100