ReactOS 0.4.15-dev-8096-ga0eec98
timerqueue.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for timerqueue.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

BOOL WINAPI BasepCreateDefaultTimerQueue (VOID)
 
BOOL WINAPI CancelTimerQueueTimer (IN HANDLE TimerQueue, IN HANDLE Timer)
 
BOOL WINAPI ChangeTimerQueueTimer (IN HANDLE TimerQueue, IN HANDLE Timer, IN ULONG DueTime, IN ULONG Period)
 
HANDLE WINAPI CreateTimerQueue (VOID)
 
BOOL WINAPI CreateTimerQueueTimer (OUT PHANDLE phNewTimer, IN HANDLE TimerQueue, IN WAITORTIMERCALLBACK Callback, IN PVOID Parameter, IN DWORD DueTime, IN DWORD Period, IN ULONG Flags)
 
BOOL WINAPI DeleteTimerQueue (IN HANDLE TimerQueue)
 
BOOL WINAPI DeleteTimerQueueEx (IN HANDLE TimerQueue, IN HANDLE CompletionEvent)
 
BOOL WINAPI DeleteTimerQueueTimer (IN HANDLE TimerQueue, IN HANDLE Timer, IN HANDLE CompletionEvent)
 
HANDLE WINAPI SetTimerQueueTimer (IN HANDLE TimerQueue, IN WAITORTIMERCALLBACK Callback, IN PVOID Parameter, IN DWORD DueTime, IN DWORD Period, IN BOOL PreferIo)
 

Variables

HANDLE BasepDefaultTimerQueue = NULL
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file timerqueue.c.

Function Documentation

◆ BasepCreateDefaultTimerQueue()

BOOL WINAPI BasepCreateDefaultTimerQueue ( VOID  )

Definition at line 25 of file timerqueue.c.

26{
28
29 /* Create the timer queue */
31 if (!NT_SUCCESS(Status))
32 {
34 DPRINT1("Unable to create the default timer queue!\n");
35 return FALSE;
36 }
37
38 return TRUE;
39}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HANDLE BasepDefaultTimerQueue
Definition: timerqueue.c:18
Status
Definition: gdiplustypes.h:25
NTSYSAPI NTSTATUS NTAPI RtlCreateTimerQueue(PHANDLE TimerQueue)
Definition: timerqueue.c:285
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166

Referenced by CreateTimerQueueTimer(), and SetTimerQueueTimer().

◆ CancelTimerQueueTimer()

BOOL WINAPI CancelTimerQueueTimer ( IN HANDLE  TimerQueue,
IN HANDLE  Timer 
)

Definition at line 49 of file timerqueue.c.

51{
53
54 if (!TimerQueue)
55 {
56 /* Use the default timer queue */
57 TimerQueue = BasepDefaultTimerQueue;
58 if (!TimerQueue)
59 {
60 /* A timer is being cancelled before one was created... fail */
62 return FALSE;
63 }
64 }
65
66 /* Delete the timer */
67 Status = RtlDeleteTimer(TimerQueue, Timer, NULL);
68 if (!NT_SUCCESS(Status))
69 {
71 return FALSE;
72 }
73
74 return TRUE;
75}
#define NULL
Definition: types.h:112
#define SetLastError(x)
Definition: compat.h:752
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
NTSYSAPI NTSTATUS NTAPI RtlDeleteTimer(_In_ HANDLE TimerQueue, _In_ HANDLE Timer, _In_ HANDLE CompletionEvent)

◆ ChangeTimerQueueTimer()

BOOL WINAPI ChangeTimerQueueTimer ( IN HANDLE  TimerQueue,
IN HANDLE  Timer,
IN ULONG  DueTime,
IN ULONG  Period 
)

Definition at line 82 of file timerqueue.c.

86{
88
89 if (!TimerQueue)
90 {
91 /* Use the default timer queue */
92 TimerQueue = BasepDefaultTimerQueue;
93 if (!TimerQueue)
94 {
95 /* A timer is being cancelled before one was created... fail */
97 return FALSE;
98 }
99 }
100
101 /* Delete the timer */
102 Status = RtlUpdateTimer(TimerQueue, Timer, DueTime, Period);
103 if (!NT_SUCCESS(Status))
104 {
106 return FALSE;
107 }
108
109 return TRUE;
110}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
NTSYSAPI NTSTATUS NTAPI RtlUpdateTimer(_In_ HANDLE TimerQueue, _In_ HANDLE Timer, _In_ ULONG DueTime, _In_ ULONG Period)
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:190
_In_ LARGE_INTEGER _In_ ULONG Period
Definition: kefuncs.h:1313

Referenced by test_timer_queue(), timer_queue_cb3(), and timer_queue_cb4().

◆ CreateTimerQueue()

HANDLE WINAPI CreateTimerQueue ( VOID  )

Definition at line 117 of file timerqueue.c.

118{
121
122 /* Create the timer queue */
124 if(!NT_SUCCESS(Status))
125 {
127 return NULL;
128 }
129
130 return Handle;
131}
ULONG Handle
Definition: gdb_input.c:15

Referenced by test_timer_queue().

◆ CreateTimerQueueTimer()

BOOL WINAPI CreateTimerQueueTimer ( OUT PHANDLE  phNewTimer,
IN HANDLE  TimerQueue,
IN WAITORTIMERCALLBACK  Callback,
IN PVOID  Parameter,
IN DWORD  DueTime,
IN DWORD  Period,
IN ULONG  Flags 
)

Definition at line 138 of file timerqueue.c.

145{
147
148 /* Parameter is not optional -- clear it now */
149 *phNewTimer = NULL;
150
151 /* Check if no queue was given */
152 if (!TimerQueue)
153 {
154 /* Create the queue if it didn't already exist */
156 {
157 return FALSE;
158 }
159
160 /* Use the default queue */
161 TimerQueue = BasepDefaultTimerQueue;
162 }
163
164 /* Create the timer. Note that no parameter checking is done here */
165 Status = RtlCreateTimer(TimerQueue,
166 phNewTimer,
167 Callback,
168 Parameter,
169 DueTime,
170 Period,
171 Flags);
172 if (!NT_SUCCESS(Status))
173 {
175 return FALSE;
176 }
177
178 return TRUE;
179}
BOOL WINAPI BasepCreateDefaultTimerQueue(VOID)
Definition: timerqueue.c:25
NTSYSAPI NTSTATUS NTAPI RtlCreateTimer(_In_ HANDLE TimerQueue, _In_ PHANDLE phNewTimer, _In_ WAITORTIMERCALLBACKFUNC Callback, _In_ PVOID Parameter, _In_ ULONG DueTime, _In_ ULONG Period, _In_ ULONG Flags)
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:323

Referenced by SHSetTimerQueueTimer(), Test1(), Test2(), Test3(), test_timer_queue(), and timer_queue_cb6().

◆ DeleteTimerQueue()

BOOL WINAPI DeleteTimerQueue ( IN HANDLE  TimerQueue)

Definition at line 186 of file timerqueue.c.

187{
188 /* We don't allow the user to delete the default timer queue */
189 if (!TimerQueue)
190 {
192 return FALSE;
193 }
194
195 /* Delete the timer queue */
196 RtlDeleteTimerQueueEx(TimerQueue, 0);
197 return TRUE;
198}
NTSYSAPI NTSTATUS NTAPI RtlDeleteTimerQueueEx(_In_ HANDLE TimerQueue, _In_opt_ HANDLE CompletionEvent)

◆ DeleteTimerQueueEx()

BOOL WINAPI DeleteTimerQueueEx ( IN HANDLE  TimerQueue,
IN HANDLE  CompletionEvent 
)

Definition at line 205 of file timerqueue.c.

207{
209
210 /* We don't allow the user to delete the default timer queue */
211 if (!TimerQueue)
212 {
214 return FALSE;
215 }
216
217 /* Delete the timer queue */
218 Status = RtlDeleteTimerQueueEx(TimerQueue, CompletionEvent);
219 if (((CompletionEvent != INVALID_HANDLE_VALUE) && (Status == STATUS_PENDING)) ||
220 !(NT_SUCCESS(Status)))
221 {
222 /* In case CompletionEvent == NULL, RtlDeleteTimerQueueEx() returns before
223 all callback routines returned. We set the last error code to STATUS_PENDING
224 and return FALSE. In case CompletionEvent == INVALID_HANDLE_VALUE we only
225 can get here if another error occured. In case CompletionEvent is something
226 else, we get here and fail, even though it isn't really an error (if Status == STATUS_PENDING).
227 We also handle all other failures the same way. */
229 return FALSE;
230 }
231
232 return TRUE;
233}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define STATUS_PENDING
Definition: ntstatus.h:82

Referenced by test_timer_queue().

◆ DeleteTimerQueueTimer()

BOOL WINAPI DeleteTimerQueueTimer ( IN HANDLE  TimerQueue,
IN HANDLE  Timer,
IN HANDLE  CompletionEvent 
)

Definition at line 240 of file timerqueue.c.

243{
245
246 if (!TimerQueue)
247 {
248 /* Use the default timer queue */
249 TimerQueue = BasepDefaultTimerQueue;
250 if (!TimerQueue)
251 {
252 /* A timer is being cancelled before one was created... fail */
254 return FALSE;
255 }
256 }
257
258 /* Delete the timer */
259 Status = RtlDeleteTimer(TimerQueue, Timer, CompletionEvent);
260 if (((CompletionEvent != INVALID_HANDLE_VALUE) && (Status == STATUS_PENDING)) ||
261 !(NT_SUCCESS(Status)))
262 {
263 /* In case CompletionEvent == NULL, RtlDeleteTimerQueueEx() returns before
264 all callback routines returned. We set the last error code to STATUS_PENDING
265 and return FALSE. In case CompletionEvent == INVALID_HANDLE_VALUE we only
266 can get here if another error occured. In case CompletionEvent is something
267 else, we get here and fail, even though it isn't really an error (if Status == STATUS_PENDING).
268 We also handle all other failures the same way. */
270 return FALSE;
271 }
272
273 return TRUE;
274}

Referenced by Test2(), Test3(), test_timer_queue(), timer_queue_cb2(), timer_queue_cb6(), and TimerCallback1().

◆ SetTimerQueueTimer()

HANDLE WINAPI SetTimerQueueTimer ( IN HANDLE  TimerQueue,
IN WAITORTIMERCALLBACK  Callback,
IN PVOID  Parameter,
IN DWORD  DueTime,
IN DWORD  Period,
IN BOOL  PreferIo 
)

Definition at line 281 of file timerqueue.c.

287{
290
291 /* Check if no queue was given */
292 if (!TimerQueue)
293 {
294 /* Create the queue if it didn't already exist */
296 {
297 return FALSE;
298 }
299
300 /* Use the default queue */
301 TimerQueue = BasepDefaultTimerQueue;
302 }
303
304 /* Create the timer */
305 Status = RtlCreateTimer(TimerQueue,
306 &Timer,
307 Callback,
308 Parameter,
309 DueTime,
310 Period,
312 if (!NT_SUCCESS(Status))
313 {
315 return NULL;
316 }
317
318 return Timer;
319}
#define WT_EXECUTEINIOTHREAD
Definition: winnt_old.h:1039
#define WT_EXECUTEDEFAULT
Definition: winnt_old.h:1038

Variable Documentation

◆ BasepDefaultTimerQueue