v1.5.0
Go to the documentation of this file.
7 #ifndef _PICO_UTIL_QUEUE_H
8 #define _PICO_UTIL_QUEUE_H
14 #ifndef PICO_QUEUE_MAX_LEVEL
15 #define PICO_QUEUE_MAX_LEVEL 0
37 uint16_t element_size;
38 uint16_t element_count;
39 #if PICO_QUEUE_MAX_LEVEL
84 int32_t rc = (int32_t)q->wptr - (int32_t)q->rptr;
86 rc += q->element_count + 1;
104 #if PICO_QUEUE_MAX_LEVEL
112 static inline uint queue_get_max_level(
queue_t *q) {
117 #if PICO_QUEUE_MAX_LEVEL
123 static inline void queue_reset_max_level(
queue_t *q) {
Definition: lock_core.h:53
void queue_free(queue_t *q)
Destroy the specified queue.
Definition: queue.c:20
bool queue_try_peek(queue_t *q, void *data)
Non-blocking peek at the next item to be removed from the queue.
Definition: queue.c:105
static uint queue_get_level(queue_t *q)
Check of level of the specified queue.
Definition: queue.h:97
static __force_inline uint32_t spin_lock_blocking(spin_lock_t *lock)
Acquire a spin lock safely.
Definition: sync.h:279
bool queue_try_remove(queue_t *q, void *data)
Non-blocking removal of entry from the queue if non empty.
Definition: queue.c:101
bool queue_try_add(queue_t *q, const void *data)
Non-blocking add value queue if not full.
Definition: queue.c:97
static uint queue_get_level_unsafe(queue_t *q)
Unsafe check of level of the specified queue.
Definition: queue.h:83
static void queue_init(queue_t *q, uint element_size, uint element_count)
Initialise a queue, allocating a (possibly shared) spinlock.
Definition: queue.h:61
static __force_inline void spin_unlock(spin_lock_t *lock, uint32_t saved_irq)
Release a spin lock safely.
Definition: sync.h:307
void queue_peek_blocking(queue_t *q, void *data)
Blocking peek at next value to be removed from queue.
Definition: queue.c:117
static bool queue_is_full(queue_t *q)
Check if queue is full.
Definition: queue.h:150
static bool queue_is_empty(queue_t *q)
Check if queue is empty.
Definition: queue.h:138
uint next_striped_spin_lock_num(void)
Return a spin lock number from the striped range.
Definition: sync.c:31
void queue_init_with_spinlock(queue_t *q, uint element_size, uint element_count, uint spinlock_num)
Initialise a queue with a specific spinlock for concurrency protection.
Definition: queue.c:11
void queue_remove_blocking(queue_t *q, void *data)
Blocking remove entry from queue.
Definition: queue.c:113
void queue_add_blocking(queue_t *q, const void *data)
Blocking add of value to queue.
Definition: queue.c:109