3 #include "pico/stdlib.h"
5 #include "pico/util/queue.h"
26 Queue(
int maxCount = 100,
bool blocking=
true,
bool withLock=
true ){
27 is_blocking = blocking;
29 queue_init_with_spinlock(&q,
sizeof(T), maxCount, nextSpinlockNumber());
31 queue_init(&q,
sizeof(T),maxCount);
42 return queue_is_empty(&q);
47 return queue_is_full(&q);
54 queue_peek_blocking(&q, (
void*) &data);
57 result = queue_try_peek(&q, (
void*) &data);
66 queue_add_blocking(&q, (
void*) &data);
69 result = queue_try_add(&q, (
void*) &data);
78 queue_remove_blocking(&q, (
void*) &data);
81 result = queue_try_remove(&q, (
void*) &data);
88 return queue_get_level(&q);
94 while(remove((
void*) &data));
101 uint nextSpinlockNumber(){
102 static uint spinlock_num;
103 return spinlock_num++;
Construct a new Pico Queue object.
Definition: PicoQueue.h:17
~Queue()
Destructor - calls queue_free.
Definition: PicoQueue.h:36
bool pop(T &data)
Gets the next element (from the head) and removes it from the queue.
Definition: PicoQueue.h:75
uint size()
Provides the number of entries in the queue.
Definition: PicoQueue.h:87
bool peek(T &data)
Reads the next element w/o removing it from the queue.
Definition: PicoQueue.h:51
bool isFull()
checks if the queue is full
Definition: PicoQueue.h:46
void clear()
clears the queue by removing all elements
Definition: PicoQueue.h:92
Queue(int maxCount=100, bool blocking=true, bool withLock=true)
Construct a new Queue object.
Definition: PicoQueue.h:26
bool push(T &data)
Adds an element (at the end) of the queue.
Definition: PicoQueue.h:63
bool isEmpty()
checks if the queue is eimpty
Definition: PicoQueue.h:41
Pico Arduino Framework.
Definition: Arduino.cpp:26