23 #ifndef ETCPAL_CPP_QUEUE_H
24 #define ETCPAL_CPP_QUEUE_H
30 #include "etcpal/common.h"
31 #include "etcpal/queue.h"
96 explicit Queue(
size_t size);
100 Queue& operator=(
const Queue& other) =
delete;
108 template <
class Rep,
class Period>
109 bool Receive(T& data,
const std::chrono::duration<Rep, Period>& timeout);
180 template <
class Rep,
class Period>
183 int timeout_ms_clamped =
184 static_cast<int>(std::min(std::chrono::milliseconds(timeout).count(),
185 static_cast<std::chrono::milliseconds::rep
>(std::numeric_limits<int>::max())));
An RTOS queue class.
Definition: queue.h:94
~Queue()
Destroy a queue.
Definition: queue.h:135
bool SendFromIsr(const T &data)
Add to a queue from an interrupt service routine.
Definition: queue.h:158
bool Reset()
Resets queue to empty state.
Definition: queue.h:202
bool ReceiveFromIsr(T &data)
Get an item from the queue from an interrupt context.
Definition: queue.h:193
bool IsEmpty() const
Check if a queue is empty.
Definition: queue.h:211
bool IsEmptyFromIsr() const
Check if a queue is empty from an interrupt service routine.
Definition: queue.h:220
bool IsFullFromIsr() const
Check if a queue is full from an interrupt service routine.
Definition: queue.h:238
bool Send(const T &data, int timeout_ms=ETCPAL_WAIT_FOREVER)
Add some data to the queue.
Definition: queue.h:149
bool Receive(T &data, int timeout_ms=ETCPAL_WAIT_FOREVER)
Get an item from the queue.
Definition: queue.h:168
Queue(size_t size)
Create a new queue.
Definition: queue.h:128
size_t SlotsUsedFromIsr() const
Get number of slots being stored in the queue from an interrupt service routine.
Definition: queue.h:256
size_t SlotsUsed() const
Get number of slots being stored in the queue.
Definition: queue.h:247
size_t SlotsAvailable() const
Get number of remaining slots in the queue.
Definition: queue.h:265
bool IsFull() const
Check if a queue is full.
Definition: queue.h:229
Common definitions used by EtcPal C++ wrappers.
bool etcpal_queue_is_empty_from_isr(const etcpal_queue_t *id)
Determine whether a queue is currently empty from an interrupt context.
Definition: queue.c:298
size_t etcpal_queue_slots_available(const etcpal_queue_t *id)
Get number of remaining slots in the queue.
Definition: queue.c:349
bool etcpal_queue_timed_receive(etcpal_queue_t *id, void *data, int timeout_ms)
Retrieve the first item from a queue, giving up after a timeout.
Definition: queue.c:247
bool etcpal_queue_send_from_isr(etcpal_queue_t *id, const void *data)
Add an item to a queue from an interrupt context.
Definition: queue.c:256
bool etcpal_queue_is_full_from_isr(const etcpal_queue_t *id)
Determine whether a queue is currently full from an interrupt context.
Definition: queue.c:318
bool etcpal_queue_is_empty(const etcpal_queue_t *id)
Determine whether a queue is currently empty.
Definition: queue.c:289
PLATFORM_DEFINED etcpal_queue_t
The queue identifier.
Definition: queue.dox:82
bool etcpal_queue_is_full(const etcpal_queue_t *id)
Determine whether a queue is currently full.
Definition: queue.c:309
bool etcpal_queue_reset(const etcpal_queue_t *id)
Resets queue to empty state.
bool etcpal_queue_receive_from_isr(etcpal_queue_t *id, void *data)
Retrieve the first item from a queue from an interrupt context.
Definition: queue.c:265
void etcpal_queue_destroy(etcpal_queue_t *id)
Destroy a queue.
Definition: queue.c:191
size_t etcpal_queue_slots_used(const etcpal_queue_t *id)
Get number of slots being stored in the queue.
Definition: queue.c:329
size_t etcpal_queue_slots_used_from_isr(const etcpal_queue_t *id)
Get number of slots being stored in the queue from an interrupt context.
Definition: queue.c:339
bool etcpal_queue_timed_send(etcpal_queue_t *id, const void *data, int timeout_ms)
Add an item to a queue, giving up after a timeout.
Definition: queue.c:229
bool etcpal_queue_create(etcpal_queue_t *id, size_t size, size_t item_size)
Create a new queue.
Definition: queue.c:142
#define ETCPAL_WAIT_FOREVER
For etcpal_ functions that take a millisecond timeout, this means to wait indefinitely.
Definition: common.h:111