1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
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:
bors[bot] 2023-10-11 12:18:43 +00:00 committed by GitHub
commit 7bc783e7af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -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();

View File

@ -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
*