mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge #19966
19966: sys/event: add event_is_queued() r=benpicco a=fabian18 Co-authored-by: Fabian Hüßler <fabian.huessler@ml-pa.com>
This commit is contained in:
commit
7bc783e7af
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "event.h"
|
||||
@ -60,6 +60,17 @@ void event_cancel(event_queue_t *queue, event_t *event)
|
||||
irq_restore(state);
|
||||
}
|
||||
|
||||
bool event_is_queued(const event_queue_t *queue, const event_t *event)
|
||||
{
|
||||
assert(queue);
|
||||
assert(event);
|
||||
|
||||
unsigned state = irq_disable();
|
||||
bool result = clist_find(&queue->event_list, &event->list_node);
|
||||
irq_restore(state);
|
||||
return result;
|
||||
}
|
||||
|
||||
event_t *event_get(event_queue_t *queue)
|
||||
{
|
||||
unsigned state = irq_disable();
|
||||
|
@ -97,6 +97,7 @@
|
||||
#define EVENT_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "assert.h"
|
||||
@ -276,6 +277,17 @@ void event_post(event_queue_t *queue, event_t *event);
|
||||
*/
|
||||
void event_cancel(event_queue_t *queue, event_t *event);
|
||||
|
||||
/**
|
||||
* @brief Check if an event is already queued
|
||||
*
|
||||
* @param[in] queue event queue to check
|
||||
* @param[in] event event to check
|
||||
*
|
||||
* @returns true if @p event is in @p queue
|
||||
* @returns false otherwise
|
||||
*/
|
||||
bool event_is_queued(const event_queue_t *queue, const event_t *event);
|
||||
|
||||
/**
|
||||
* @brief Get next event from event queue, non-blocking
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user