libnx  v4.2.0
uevent.h
Go to the documentation of this file.
1 /**
2  * @file uevent.h
3  * @brief User-mode event synchronization primitive.
4  * @author plutoo
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "wait.h"
9 
10 typedef struct UEvent UEvent;
11 
12 /// User-mode event object.
13 struct UEvent {
14  Waitable waitable;
15  bool signal;
16  bool auto_clear;
17 };
18 
19 /// Creates a waiter for a user-mode event.
20 static inline Waiter waiterForUEvent(UEvent* e)
21 {
22  Waiter wait_obj;
23  wait_obj.type = WaiterType_Waitable;
24  wait_obj.waitable = &e->waitable;
25  return wait_obj;
26 }
27 
28 /**
29  * @brief Creates a user-mode event.
30  * @param[out] e UEvent object.
31  * @param[in] auto_clear Whether to automatically clear the event.
32  * @note It is safe to wait on this event with several threads simultaneously.
33  * @note If more than one thread is listening on it, at least one thread will get the signal. No other guarantees.
34  */
35 void ueventCreate(UEvent* e, bool auto_clear);
36 
37 /**
38  * @brief Clears the event signal.
39  * @param[in] e UEvent object.
40  */
41 void ueventClear(UEvent* e);
42 
43 /**
44  * @brief Signals the event.
45  * @param[in] e UEvent object.
46  */
47 void ueventSignal(UEvent* e);
ueventClear
void ueventClear(UEvent *e)
Clears the event signal.
wait.h
User mode synchronization primitive waiting operations.
Waitable
Definition: wait.h:21
ueventCreate
void ueventCreate(UEvent *e, bool auto_clear)
Creates a user-mode event.
Waiter
Waiter structure, representing any generic waitable synchronization object; both kernel-mode and user...
Definition: wait.h:36
ueventSignal
void ueventSignal(UEvent *e)
Signals the event.
waiterForUEvent
static Waiter waiterForUEvent(UEvent *e)
Creates a waiter for a user-mode event.
Definition: uevent.h:20
UEvent
User-mode event object.
Definition: uevent.h:13