mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:12:57 +01:00
sys/event: add event_wait_timeout64()
This commit is contained in:
parent
fc40b54cae
commit
e06cbce940
@ -115,14 +115,12 @@ event_t *event_wait(event_queue_t *queue)
|
||||
}
|
||||
|
||||
#ifdef MODULE_XTIMER
|
||||
event_t *event_wait_timeout(event_queue_t *queue, uint32_t timeout)
|
||||
static event_t *_wait_timeout(event_queue_t *queue, xtimer_t *timer)
|
||||
{
|
||||
assert(queue);
|
||||
event_t *result;
|
||||
xtimer_t timer;
|
||||
thread_flags_t flags = 0;
|
||||
|
||||
xtimer_set_timeout_flag(&timer, timeout);
|
||||
do {
|
||||
result = event_get(queue);
|
||||
if (result == NULL) {
|
||||
@ -131,11 +129,27 @@ event_t *event_wait_timeout(event_queue_t *queue, uint32_t timeout)
|
||||
} while ((result == NULL) && (flags & THREAD_FLAG_EVENT));
|
||||
|
||||
if (result) {
|
||||
xtimer_remove(&timer);
|
||||
xtimer_remove(timer);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
event_t *event_wait_timeout(event_queue_t *queue, uint32_t timeout)
|
||||
{
|
||||
xtimer_t timer;
|
||||
|
||||
xtimer_set_timeout_flag(&timer, timeout);
|
||||
return _wait_timeout(queue, &timer);
|
||||
}
|
||||
|
||||
event_t *event_wait_timeout64(event_queue_t *queue, uint64_t timeout)
|
||||
{
|
||||
xtimer_t timer;
|
||||
|
||||
xtimer_set_timeout_flag64(&timer, timeout);
|
||||
return _wait_timeout(queue, &timer);
|
||||
}
|
||||
#endif
|
||||
|
||||
void event_loop(event_queue_t *queue)
|
||||
|
@ -242,6 +242,17 @@ event_t *event_wait(event_queue_t *queue);
|
||||
* @return NULL if timeout expired before an event was posted
|
||||
*/
|
||||
event_t *event_wait_timeout(event_queue_t *queue, uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Get next event from event queue, blocking until timeout expires
|
||||
*
|
||||
* @param[in] queue queue to query for an event
|
||||
* @param[in] timeout maximum time to wait for an event to be posted in us
|
||||
*
|
||||
* @return pointer to next event if event was taken from the queue
|
||||
* @return NULL if timeout expired before an event was posted
|
||||
*/
|
||||
event_t *event_wait_timeout64(event_queue_t *queue, uint64_t timeout);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user