|
58 | 58 | #define THREAD_FLAGS_H |
59 | 59 |
|
60 | 60 | #include "sched.h" /* for thread_t typedef */ |
| 61 | +#include "mbox.h" |
61 | 62 |
|
62 | 63 | #ifdef __cplusplus |
63 | 64 | extern "C" { |
@@ -101,6 +102,10 @@ extern "C" { |
101 | 102 | * @see xtimer_set_timeout_flag |
102 | 103 | */ |
103 | 104 | #define THREAD_FLAG_TIMEOUT (1u << 14) |
| 105 | +/** |
| 106 | + * @brief Flag used to wake @ref thread_flags_wait_any_or_mbox |
| 107 | + */ |
| 108 | +#define THREAD_FLAG_MBOX_READY (1u << 13) |
104 | 109 |
|
105 | 110 | /** |
106 | 111 | * @brief Comprehensive set of all predefined flags |
@@ -170,6 +175,30 @@ thread_flags_t thread_flags_wait_any(thread_flags_t mask); |
170 | 175 | */ |
171 | 176 | thread_flags_t thread_flags_wait_all(thread_flags_t mask); |
172 | 177 |
|
| 178 | +/** |
| 179 | + * @brief Wait for any flag or a message via mbox, whatever comes first |
| 180 | + * |
| 181 | + * @param[in,out] mbox ptr to the mailbox to operate on |
| 182 | + * @param[out] msg destination where to store the retrieved message |
| 183 | + * @param[in] mask thread_flags mask to wait on |
| 184 | + * |
| 185 | + * @post Either a thread flag matching @p mask came in, was cleared and the |
| 186 | + * value of the cleared flag is returned, or a message was retrieved |
| 187 | + * from @p mbox, stored into @p msg and `0` was returned. |
| 188 | + * |
| 189 | + * @retval 0 A message came in first |
| 190 | + * @retval !=0 A flag came in first, the flag was cleared and is retuned |
| 191 | + * @return The flags that caused the wake up, or `0` if a message came in first |
| 192 | + * |
| 193 | + * @note This is only available when module @ref core_mbox is used |
| 194 | + * |
| 195 | + * @warning This API is not yet ***stable*** and was rushed into a release as |
| 196 | + * infrastructure for a bugfix. It is recommended that user do not |
| 197 | + * jump on this API as of now. |
| 198 | + */ |
| 199 | +thread_flags_t thread_flags_wait_any_or_mbox(mbox_t *mbox, msg_t *msg, |
| 200 | + thread_flags_t mask); |
| 201 | + |
173 | 202 | /** |
174 | 203 | * @brief Wait for any flags in mask to become set (blocking), one at a time |
175 | 204 | * |
|
0 commit comments