libnx  v4.2.2
async.h
Go to the documentation of this file.
1 /**
2  * @file async.h
3  * @brief NS/NIM IAsync* IPC wrapper.
4  * @author yellows8
5  * @copyright libnx Authors
6  */
7 #pragma once
8 #include "../types.h"
9 #include "../sf/service.h"
10 #include "../applets/error.h"
11 #include "../kernel/event.h"
12 
13 /// AsyncValue
14 typedef struct {
15  Service s; ///< IAsyncValue
16  Event event; ///< Event with autoclear=false.
17 } AsyncValue;
18 
19 /// AsyncResult
20 typedef struct {
21  Service s; ///< IAsyncResult
22  Event event; ///< Event with autoclear=false.
23 } AsyncResult;
24 
25 ///@name IAsyncValue
26 ///@{
27 
28 /**
29  * @brief Close a \ref AsyncValue.
30  * @note When the object is initialized, this uses \ref asyncValueCancel then \ref asyncValueWait with timeout=UINT64_MAX.
31  * @param a \ref AsyncValue
32  */
34 
35 /**
36  * @brief Waits for the async operation to finish using the specified timeout.
37  * @param a \ref AsyncValue
38  * @param[in] timeout Timeout in nanoseconds. UINT64_MAX for no timeout.
39  */
40 Result asyncValueWait(AsyncValue *a, u64 timeout);
41 
42 /**
43  * @brief Gets the value size.
44  * @param a \ref AsyncValue
45  * @param[out] size Output size.
46  */
48 
49 /**
50  * @brief Gets the value.
51  * @note Prior to using the cmd, this uses \ref asyncResultWait with timeout=UINT64_MAX.
52  * @param a \ref AsyncValue
53  * @param[out] buffer Output buffer.
54  * @param[in] size Output buffer size.
55  */
56 Result asyncValueGet(AsyncValue *a, void* buffer, size_t size);
57 
58 /**
59  * @brief Cancels the async operation.
60  * @note Used automatically by \ref asyncValueClose.
61  * @param a \ref AsyncValue
62  */
64 
65 /**
66  * @brief Gets the \ref ErrorContext.
67  * @note Only available on [4.0.0+].
68  * @param a \ref AsyncValue
69  * @param[out] context \ref ErrorContext
70  */
72 
73 ///@}
74 
75 ///@name IAsyncResult
76 ///@{
77 
78 /**
79  * @brief Close a \ref AsyncResult.
80  * @note When the object is initialized, this uses \ref asyncResultCancel then \ref asyncResultWait with timeout=UINT64_MAX.
81  * @param a \ref AsyncResult
82  */
84 
85 /**
86  * @brief Waits for the async operation to finish using the specified timeout.
87  * @param a \ref AsyncResult
88  * @param[in] timeout Timeout in nanoseconds. UINT64_MAX for no timeout.
89  */
91 
92 /**
93  * @brief Gets the Result.
94  * @note Prior to using the cmd, this uses \ref asyncResultWait with timeout=UINT64_MAX.
95  * @param a \ref AsyncResult
96  */
98 
99 /**
100  * @brief Cancels the async operation.
101  * @note Used automatically by \ref asyncResultClose.
102  * @param a \ref AsyncResult
103  */
105 
106 /**
107  * @brief Gets the \ref ErrorContext.
108  * @note Only available on [4.0.0+].
109  * @param a \ref AsyncResult
110  * @param[out] context \ref ErrorContext
111  */
113 
114 ///@}
115 
asyncValueGetSize
Result asyncValueGetSize(AsyncValue *a, u64 *size)
Gets the value size.
Event
Kernel-mode event structure.
Definition: event.h:13
AsyncResult
AsyncResult.
Definition: async.h:20
asyncValueClose
void asyncValueClose(AsyncValue *a)
Close a AsyncValue.
AsyncValue
AsyncValue.
Definition: async.h:14
u64
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
asyncValueCancel
Result asyncValueCancel(AsyncValue *a)
Cancels the async operation.
asyncValueGet
Result asyncValueGet(AsyncValue *a, void *buffer, size_t size)
Gets the value.
Result
u32 Result
Function error code result type.
Definition: types.h:44
AsyncValue::event
Event event
Event with autoclear=false.
Definition: async.h:16
AsyncResult::s
Service s
IAsyncResult.
Definition: async.h:21
asyncResultWait
Result asyncResultWait(AsyncResult *a, u64 timeout)
Waits for the async operation to finish using the specified timeout.
AsyncResult::event
Event event
Event with autoclear=false.
Definition: async.h:22
AsyncValue::s
Service s
IAsyncValue.
Definition: async.h:15
ErrorContext
Error context.
Definition: error.h:38
Service
Service object structure.
Definition: service.h:13
asyncValueGetErrorContext
Result asyncValueGetErrorContext(AsyncValue *a, ErrorContext *context)
Gets the ErrorContext.
asyncResultClose
void asyncResultClose(AsyncResult *a)
Close a AsyncResult.
asyncValueWait
Result asyncValueWait(AsyncValue *a, u64 timeout)
Waits for the async operation to finish using the specified timeout.
asyncResultGetErrorContext
Result asyncResultGetErrorContext(AsyncResult *a, ErrorContext *context)
Gets the ErrorContext.
asyncResultGet
Result asyncResultGet(AsyncResult *a)
Gets the Result.
asyncResultCancel
Result asyncResultCancel(AsyncResult *a)
Cancels the async operation.