ReactOS 0.4.16-dev-983-g23ad936
timerqueue.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS system libraries
4 * PURPOSE: Timer Queue implementation
5 * FILE: lib/rtl/timerqueue.c
6 * PROGRAMMER:
7 */
8
9/* INCLUDES *****************************************************************/
10
11#include <rtl.h>
12
13#define NDEBUG
14#include <debug.h>
15
16#undef LIST_FOR_EACH
17#undef LIST_FOR_EACH_SAFE
18#include <wine/list.h>
19
20/* FUNCTIONS ***************************************************************/
21
25
28{
30}
31
33{
34 if (timeout == INFINITE) return NULL;
35 pTime->QuadPart = (ULONGLONG)timeout * -10000;
36 return pTime;
37}
38
39struct timer_queue;
40struct queue_timer
41{
42 struct timer_queue *q;
43 struct list entry;
44 ULONG runcount; /* number of callbacks pending execution */
50 BOOL destroy; /* timer should be deleted; once set, never unset */
51 HANDLE event; /* removal event */
52};
53
54struct timer_queue
55{
58 struct list timers; /* sorted by expiration time */
59 BOOL quit; /* queue should be deleted; once set, never unset */
62};
63
64#define EXPIRE_NEVER (~(ULONGLONG) 0)
65#define TIMER_QUEUE_MAGIC 0x516d6954 /* TimQ */
66
70 HANDLE TimerQueue,
71 PHANDLE NewTimer,
77{
78 return RtlCreateTimer(TimerQueue,
79 NewTimer,
82 DueTime,
83 Period,
84 Flags);
85}
86
87/*
88 * @implemented
89 */
93{
94 return RtlDeleteTimer(TimerQueue, Timer, NULL);
95}
96
97/*
98 * @implemented
99 */
101NTAPI
103{
105}
106
107/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
Definition: list.h:37
#define STATUS_NOT_IMPLEMENTED
Definition: d3dkmdt.h:42
#define NULL
Definition: types.h:112
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI NTSTATUS NTAPI RtlDeleteTimer(_In_ HANDLE TimerQueue, _In_ HANDLE Timer, _In_ HANDLE CompletionEvent)
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)
NTSYSAPI NTSTATUS NTAPI RtlDeleteTimerQueueEx(_In_ HANDLE TimerQueue, _In_opt_ HANDLE CompletionEvent)
NTSTATUS(NTAPI * PRTL_START_POOL_THREAD)(_In_ PTHREAD_START_ROUTINE Function, _In_ PVOID Parameter, _Out_ PHANDLE ThreadHandle)
Definition: rtltypes.h:574
NTSTATUS(NTAPI * PRTL_EXIT_POOL_THREAD)(_In_ NTSTATUS ExitStatus)
Definition: rtltypes.h:581
VOID(NTAPI * WAITORTIMERCALLBACKFUNC)(PVOID pvContext, BOOLEAN fTimerOrWaitFired)
Definition: rtltypes.h:490
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
static PLARGE_INTEGER get_nt_timeout(PLARGE_INTEGER pTime, ULONG timeout)
Definition: timerqueue.c:32
HANDLE TimerThreadHandle
Definition: timerqueue.c:24
NTSTATUS NTAPI RtlDeleteTimerQueue(HANDLE TimerQueue)
Definition: timerqueue.c:102
NTSTATUS NTAPI RtlCancelTimer(HANDLE TimerQueue, HANDLE Timer)
Definition: timerqueue.c:92
PRTL_EXIT_POOL_THREAD RtlpExitThreadFunc
Definition: workitem.c:46
NTSTATUS WINAPI RtlSetTimer(HANDLE TimerQueue, PHANDLE NewTimer, WAITORTIMERCALLBACKFUNC Callback, PVOID Parameter, DWORD DueTime, DWORD Period, ULONG Flags)
Definition: timerqueue.c:69
NTSTATUS RtlpInitializeTimerThread(VOID)
Definition: timerqueue.c:27
PRTL_START_POOL_THREAD RtlpStartThreadFunc
Definition: workitem.c:45
BOOL destroy
Definition: threadpool.c:126
DWORD period
Definition: threadpool.c:123
WAITORTIMERCALLBACKFUNC callback
Definition: timerqueue.c:45
ULONG runcount
Definition: threadpool.c:120
struct timer_queue * q
Definition: threadpool.c:118
PVOID param
Definition: threadpool.c:122
HANDLE event
Definition: threadpool.c:127
ULONG flags
Definition: threadpool.c:124
ULONGLONG expire
Definition: threadpool.c:125
struct list entry
Definition: threadpool.c:119
Definition: dhcpd.h:245
HANDLE event
Definition: threadpool.c:136
RTL_CRITICAL_SECTION cs
Definition: threadpool.c:133
HANDLE thread
Definition: threadpool.c:137
DWORD magic
Definition: threadpool.c:132
struct list timers
Definition: threadpool.c:134
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
_In_ WDFINTERRUPT _In_ PFN_WDF_INTERRUPT_SYNCHRONIZE Callback
Definition: wdfinterrupt.h:458
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:190
_In_ PCCERT_CONTEXT _In_opt_ LPFILETIME pTime
Definition: wincrypt.h:4837
#define WINAPI
Definition: msvc.h:6
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_In_ LARGE_INTEGER _In_ ULONG Period
Definition: kefuncs.h:1313
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336