-
Notifications
You must be signed in to change notification settings - Fork 240
Kernel events
Raymond Chen edited this page Aug 24, 2020
·
1 revision
wil::kernel_event_t
is a family of classes defined in wil/resource.h
as part of the RAII resource wrappers library.
It is very similar to wil::unique_event
(see Event handles)
but for use in kernel-mode code. It wraps a
KEVENT
.
This is a very lightweight class that exists primarily for the benefit of
automatic initialization on construction.
The two variants of this class are:
-
wil::kernel_event_auto_reset
, also known aswil::kernel_event
. The event becomes reset when a waiting thread is released. This is aKEVENT
of typeSynchronizationEvent
. -
wil::kernel_event_manual_reset
. The event remains set until explicitly reset. This is aKEVENT
of typeNotificationEvent
.
Sample usage:
// Default state is not signaled.
wil::kernel_event finished;
// Time is specified in 100ns units, like in KeWaitForSingleObject.
if (!finished.wait(-1ll * 1 * 1000 * 1000 * 1000 / 100))
{
finished.set();
}
// Wait indefinitely.
finished.wait();
Class summary:
Constructors
-
kernel_event_t(bool isSignaled = false)
: Construct an event with initial state as specified.
Methods
-
PRKEVENT get()
: Obtain a pointer to the underlyingKEVENT
. -
void set(KPRIORITY increment = IO_NO_INCREMENT)
: Sets the event by callingKeSetEvent
with the specified priority increment. -
void clear()
: Clears the event by callingKeClearEvent
. -
bool is_signaled()
: Checks whether the event is signaled without changing its state. -
void wait()
: Wait indefinitely for the event to be set. -
bool wait(LONGLONG waitTime)
: Wait for the event to be set, up to a relative or absolute point in time. Returnstrue
if the wait succeeded, orfalse
if the wait timed out. The time is specified in a manner similar to that inKeWaitForSingleObject
.