libnx  v4.8.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  */
42 
43 /**
44  * @brief Signals the event.
45  * @param[in] e UEvent object.
46  */
User-mode event object.
Definition: uevent.h:13
Definition: wait.h:21
Waiter structure, representing any generic waitable synchronization object; both kernel-mode and user...
Definition: wait.h:36
static Waiter waiterForUEvent(UEvent *e)
Creates a waiter for a user-mode event.
Definition: uevent.h:20
void ueventSignal(UEvent *e)
Signals the event.
void ueventClear(UEvent *e)
Clears the event signal.
void ueventCreate(UEvent *e, bool auto_clear)
Creates a user-mode event.
User mode synchronization primitive waiting operations.