idfxx 1.0.0
Modern C++23 components for ESP-IDF
Loading...
Searching...
No Matches
idfxx::queue< T > Class Template Reference

Type-safe inter-task message queue. More...

Classes

struct  isr_receive_result
 Result of an ISR receive operation. More...
 
struct  isr_send_result
 Result of an ISR send operation. More...
 

Public Member Functions

 queue (size_t length, flags< memory_caps > mem_caps=memory_caps::dram)
 Creates a queue with the specified capacity.
 
 ~queue ()
 Destroys the queue and releases all resources.
 
 queue (const queue &)=delete
 
queueoperator= (const queue &)=delete
 
 queue (queue &&other) noexcept
 Move constructor.
 
queueoperator= (queue &&other) noexcept
 Move assignment.
 
void send (const T &item)
 Sends an item to the back of the queue, blocking indefinitely.
 
template<typename Rep , typename Period >
void send (const T &item, const std::chrono::duration< Rep, Period > &timeout)
 Sends an item to the back of the queue with a timeout.
 
template<typename Clock , typename Duration >
void send_until (const T &item, const std::chrono::time_point< Clock, Duration > &deadline)
 Sends an item to the back of the queue with a deadline.
 
void send_to_front (const T &item)
 Sends an item to the front of the queue, blocking indefinitely.
 
template<typename Rep , typename Period >
void send_to_front (const T &item, const std::chrono::duration< Rep, Period > &timeout)
 Sends an item to the front of the queue with a timeout.
 
template<typename Clock , typename Duration >
void send_to_front_until (const T &item, const std::chrono::time_point< Clock, Duration > &deadline)
 Sends an item to the front of the queue with a deadline.
 
result< voidtry_send (const T &item)
 Sends an item to the back of the queue, blocking indefinitely.
 
template<typename Rep , typename Period >
result< voidtry_send (const T &item, const std::chrono::duration< Rep, Period > &timeout)
 Sends an item to the back of the queue with a timeout.
 
template<typename Clock , typename Duration >
result< voidtry_send_until (const T &item, const std::chrono::time_point< Clock, Duration > &deadline)
 Sends an item to the back of the queue with a deadline.
 
result< voidtry_send_to_front (const T &item)
 Sends an item to the front of the queue, blocking indefinitely.
 
template<typename Rep , typename Period >
result< voidtry_send_to_front (const T &item, const std::chrono::duration< Rep, Period > &timeout)
 Sends an item to the front of the queue with a timeout.
 
template<typename Clock , typename Duration >
result< voidtry_send_to_front_until (const T &item, const std::chrono::time_point< Clock, Duration > &deadline)
 Sends an item to the front of the queue with a deadline.
 
void overwrite (const T &item) noexcept
 Overwrites the last item in the queue, or sends if the queue is not full.
 
T receive ()
 Receives an item from the queue, blocking indefinitely.
 
template<typename Rep , typename Period >
T receive (const std::chrono::duration< Rep, Period > &timeout)
 Receives an item from the queue with a timeout.
 
template<typename Clock , typename Duration >
T receive_until (const std::chrono::time_point< Clock, Duration > &deadline)
 Receives an item from the queue with a deadline.
 
result< Ttry_receive ()
 Receives an item from the queue, blocking indefinitely.
 
template<typename Rep , typename Period >
result< Ttry_receive (const std::chrono::duration< Rep, Period > &timeout)
 Receives an item from the queue with a timeout.
 
template<typename Clock , typename Duration >
result< Ttry_receive_until (const std::chrono::time_point< Clock, Duration > &deadline)
 Receives an item from the queue with a deadline.
 
T peek ()
 Peeks at the front item in the queue without removing it, blocking indefinitely.
 
template<typename Rep , typename Period >
T peek (const std::chrono::duration< Rep, Period > &timeout)
 Peeks at the front item in the queue without removing it, with a timeout.
 
template<typename Clock , typename Duration >
T peek_until (const std::chrono::time_point< Clock, Duration > &deadline)
 Peeks at the front item in the queue without removing it, with a deadline.
 
result< Ttry_peek ()
 Peeks at the front item in the queue without removing it, blocking indefinitely.
 
template<typename Rep , typename Period >
result< Ttry_peek (const std::chrono::duration< Rep, Period > &timeout)
 Peeks at the front item in the queue without removing it, with a timeout.
 
template<typename Clock , typename Duration >
result< Ttry_peek_until (const std::chrono::time_point< Clock, Duration > &deadline)
 Peeks at the front item in the queue without removing it, with a deadline.
 
isr_send_result IRAM_ATTR send_from_isr (const T &item) noexcept
 Sends an item to the back of the queue from ISR context.
 
isr_send_result IRAM_ATTR send_to_front_from_isr (const T &item) noexcept
 Sends an item to the front of the queue from ISR context.
 
bool IRAM_ATTR overwrite_from_isr (const T &item) noexcept
 Overwrites the last item in the queue from ISR context.
 
isr_receive_result IRAM_ATTR receive_from_isr () noexcept
 Receives an item from the queue in ISR context.
 
std::optional< T > IRAM_ATTR peek_from_isr () const noexcept
 Peeks at the front item in the queue from ISR context without removing it.
 
size_t size () const noexcept
 Returns the number of items currently in the queue.
 
size_t available () const noexcept
 Returns the number of free spaces in the queue.
 
bool empty () const noexcept
 Checks if the queue is empty.
 
bool full () const noexcept
 Checks if the queue is full.
 
QueueHandle_t idf_handle () const noexcept
 Returns the underlying FreeRTOS queue handle.
 
void reset () noexcept
 Removes all items from the queue.
 

Static Public Member Functions

static result< queuemake (size_t length, flags< memory_caps > mem_caps=memory_caps::dram)
 Creates a queue with the specified capacity.
 

Detailed Description

template<typename T>
requires std::is_trivially_copyable_v<T>
class idfxx::queue< T >

Type-safe inter-task message queue.

A fixed-size, FIFO message queue for passing messages between tasks and between ISRs and tasks. Messages are copied into and out of the queue by value.

This type is non-copyable and move-only. Result-returning methods on a moved-from object return errc::invalid_state. Simple accessors return default/null values.

Template Parameters
TThe message type. Must be trivially copyable.
// Create a queue that can hold up to 10 integers
// Send and receive
q.send(42);
int value = q.receive();
// With timeout
q.send(99, 100ms);
int value2 = q.receive(100ms);
std::expected< T, std::error_code > result
result type wrapping a value or error code.
Definition error.hpp:120

Definition at line 67 of file queue.hpp.

Constructor & Destructor Documentation

◆ queue() [1/3]

template<typename T >
idfxx::queue< T >::queue ( size_t  length,
flags< memory_caps mem_caps = memory_caps::dram 
)
inlineexplicit

Creates a queue with the specified capacity.

Parameters
lengthMaximum number of items the queue can hold.
mem_capsMemory capability flags for queue storage allocation.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::invalid_arg if length is 0.
std::bad_allocif memory allocation fails.

Definition at line 79 of file queue.hpp.

References idfxx::invalid_arg, and idfxx::to_underlying().

◆ ~queue()

template<typename T >
idfxx::queue< T >::~queue ( )
inline

Destroys the queue and releases all resources.

Any items remaining in the queue are discarded.

Definition at line 116 of file queue.hpp.

◆ queue() [2/3]

template<typename T >
idfxx::queue< T >::queue ( const queue< T > &  )
delete

◆ queue() [3/3]

template<typename T >
idfxx::queue< T >::queue ( queue< T > &&  other)
inlinenoexcept

Move constructor.

Transfers queue ownership.

Definition at line 126 of file queue.hpp.

Member Function Documentation

◆ available()

template<typename T >
size_t idfxx::queue< T >::available ( ) const
inlinenoexcept

Returns the number of free spaces in the queue.

Returns
The number of items that can be sent before the queue is full.

Definition at line 747 of file queue.hpp.

◆ empty()

template<typename T >
bool idfxx::queue< T >::empty ( ) const
inlinenoexcept

Checks if the queue is empty.

Returns
true if the queue contains no items, false otherwise.

Definition at line 759 of file queue.hpp.

◆ full()

template<typename T >
bool idfxx::queue< T >::full ( ) const
inlinenoexcept

Checks if the queue is full.

Returns
true if the queue has no free spaces, false otherwise.

Definition at line 771 of file queue.hpp.

◆ idf_handle()

template<typename T >
QueueHandle_t idfxx::queue< T >::idf_handle ( ) const
inlinenoexcept

Returns the underlying FreeRTOS queue handle.

Provides access to the raw handle for interoperability with ESP-IDF APIs that require a QueueHandle_t.

Returns
The QueueHandle_t.

Definition at line 786 of file queue.hpp.

◆ make()

template<typename T >
static result< queue > idfxx::queue< T >::make ( size_t  length,
flags< memory_caps mem_caps = memory_caps::dram 
)
inlinestatic

Creates a queue with the specified capacity.

Parameters
lengthMaximum number of items the queue can hold.
mem_capsMemory capability flags for queue storage allocation.
Returns
The new queue, or an error.
Return values
invalid_arglength is 0.

Definition at line 99 of file queue.hpp.

References idfxx::error(), idfxx::invalid_arg, and idfxx::to_underlying().

◆ operator=() [1/2]

template<typename T >
queue & idfxx::queue< T >::operator= ( const queue< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
queue & idfxx::queue< T >::operator= ( queue< T > &&  other)
inlinenoexcept

Move assignment.

Transfers queue ownership.

Definition at line 130 of file queue.hpp.

◆ overwrite()

template<typename T >
void idfxx::queue< T >::overwrite ( const T item)
inlinenoexcept

Overwrites the last item in the queue, or sends if the queue is not full.

If the queue is full, the most recently written item is overwritten. If the queue is not full, the item is added to the back. This is most useful with a queue of length 1 to implement a "latest value" mailbox.

This operation never blocks and always succeeds.

Parameters
itemThe item to write.

Definition at line 360 of file queue.hpp.

◆ overwrite_from_isr()

template<typename T >
bool IRAM_ATTR idfxx::queue< T >::overwrite_from_isr ( const T item)
inlinenoexcept

Overwrites the last item in the queue from ISR context.

If the queue is full, the most recently written item is overwritten. This operation always succeeds.

Parameters
itemThe item to write.
Returns
true if a context switch should be requested, false otherwise.
Note
Pass the return value to idfxx::yield_from_isr() to perform the context switch if needed.
void IRAM_ATTR my_isr() {
bool yield = q->overwrite_from_isr(latest_value);
}
void yield_from_isr(bool higher_priority_task_woken=true) noexcept
Requests a context switch from ISR context.
void yield() noexcept
Yields execution to other ready tasks of equal priority.
Definition sched.hpp:87

Definition at line 662 of file queue.hpp.

◆ peek() [1/2]

template<typename T >
T idfxx::queue< T >::peek ( )
inline

Peeks at the front item in the queue without removing it, blocking indefinitely.

Blocks until an item is available. The item remains in the queue after peeking.

Returns
A copy of the front item.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains empty.

Definition at line 480 of file queue.hpp.

References idfxx::queue< T >::try_peek(), and idfxx::unwrap().

◆ peek() [2/2]

template<typename T >
template<typename Rep , typename Period >
T idfxx::queue< T >::peek ( const std::chrono::duration< Rep, Period > &  timeout)
inline

Peeks at the front item in the queue without removing it, with a timeout.

Blocks until an item is available or the timeout expires. The item remains in the queue after peeking.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
timeoutMaximum time to wait for an item.
Returns
A copy of the front item.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains empty for the duration.

Definition at line 497 of file queue.hpp.

References idfxx::timeout, idfxx::queue< T >::try_peek(), and idfxx::unwrap().

◆ peek_from_isr()

template<typename T >
std::optional< T > IRAM_ATTR idfxx::queue< T >::peek_from_isr ( ) const
inlinenoexcept

Peeks at the front item in the queue from ISR context without removing it.

Returns
The front item, or std::nullopt if the queue is empty.
void IRAM_ATTR my_isr() {
if (auto item = q->peek_from_isr()) {
// inspect *item without removing it
}
}

Definition at line 715 of file queue.hpp.

◆ peek_until()

template<typename T >
T idfxx::queue< T >::peek_until ( const std::chrono::time_point< Clock, Duration > &  deadline)
inline

Peeks at the front item in the queue without removing it, with a deadline.

Blocks until an item is available or the deadline is reached. The item remains in the queue after peeking.

Template Parameters
ClockThe clock type.
DurationThe duration type of the time point.
Parameters
deadlineThe time point at which to stop waiting.
Returns
A copy of the front item.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains empty until the deadline.

Definition at line 516 of file queue.hpp.

References idfxx::queue< T >::try_peek_until(), and idfxx::unwrap().

◆ receive() [1/2]

template<typename T >
T idfxx::queue< T >::receive ( )
inline

Receives an item from the queue, blocking indefinitely.

Blocks until an item is available.

Returns
The received item.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains empty.

Definition at line 381 of file queue.hpp.

References idfxx::queue< T >::try_receive(), and idfxx::unwrap().

◆ receive() [2/2]

template<typename T >
template<typename Rep , typename Period >
T idfxx::queue< T >::receive ( const std::chrono::duration< Rep, Period > &  timeout)
inline

Receives an item from the queue with a timeout.

Blocks until an item is available or the timeout expires.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
timeoutMaximum time to wait for an item.
Returns
The received item.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains empty for the duration.

Definition at line 397 of file queue.hpp.

References idfxx::timeout, idfxx::queue< T >::try_receive(), and idfxx::unwrap().

◆ receive_from_isr()

template<typename T >
isr_receive_result IRAM_ATTR idfxx::queue< T >::receive_from_isr ( )
inlinenoexcept

Receives an item from the queue in ISR context.

Returns
Result containing the received item (or std::nullopt if the queue was empty) and whether a context switch should be requested.
Note
Pass the yield field to idfxx::yield_from_isr() to perform the context switch if needed.
void IRAM_ATTR my_isr() {
auto [item, yield] = q->receive_from_isr();
if (item) {
// process *item
}
}

Definition at line 690 of file queue.hpp.

◆ receive_until()

template<typename T >
T idfxx::queue< T >::receive_until ( const std::chrono::time_point< Clock, Duration > &  deadline)
inline

Receives an item from the queue with a deadline.

Blocks until an item is available or the deadline is reached.

Template Parameters
ClockThe clock type.
DurationThe duration type of the time point.
Parameters
deadlineThe time point at which to stop waiting.
Returns
The received item.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains empty until the deadline.

Definition at line 415 of file queue.hpp.

References idfxx::queue< T >::try_receive_until(), and idfxx::unwrap().

◆ reset()

template<typename T >
void idfxx::queue< T >::reset ( )
inlinenoexcept

Removes all items from the queue.

After reset, the queue is empty and all previously stored items are discarded.

Definition at line 793 of file queue.hpp.

◆ send() [1/2]

template<typename T >
void idfxx::queue< T >::send ( const T item)
inline

Sends an item to the back of the queue, blocking indefinitely.

Blocks until space is available in the queue.

Parameters
itemThe item to send.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains full.

Definition at line 154 of file queue.hpp.

References idfxx::queue< T >::try_send(), and idfxx::unwrap().

◆ send() [2/2]

template<typename T >
template<typename Rep , typename Period >
void idfxx::queue< T >::send ( const T item,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Sends an item to the back of the queue with a timeout.

Blocks until space is available or the timeout expires.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
itemThe item to send.
timeoutMaximum time to wait for space.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains full for the duration.

Definition at line 170 of file queue.hpp.

References idfxx::timeout, idfxx::queue< T >::try_send(), and idfxx::unwrap().

◆ send_from_isr()

template<typename T >
isr_send_result IRAM_ATTR idfxx::queue< T >::send_from_isr ( const T item)
inlinenoexcept

Sends an item to the back of the queue from ISR context.

Parameters
itemThe item to send.
Returns
Result containing success status and whether a context switch should be requested.
Note
Pass the yield field to idfxx::yield_from_isr() to perform the context switch if needed.
void IRAM_ATTR my_isr() {
auto [success, yield] = q->send_from_isr(value);
}

Definition at line 608 of file queue.hpp.

◆ send_to_front() [1/2]

template<typename T >
void idfxx::queue< T >::send_to_front ( const T item)
inline

Sends an item to the front of the queue, blocking indefinitely.

Blocks until space is available in the queue. The item is placed at the front, so it will be the next item received.

Parameters
itemThe item to send.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains full.

Definition at line 202 of file queue.hpp.

References idfxx::queue< T >::try_send_to_front(), and idfxx::unwrap().

◆ send_to_front() [2/2]

template<typename T >
template<typename Rep , typename Period >
void idfxx::queue< T >::send_to_front ( const T item,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Sends an item to the front of the queue with a timeout.

Blocks until space is available or the timeout expires. The item is placed at the front, so it will be the next item received.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
itemThe item to send.
timeoutMaximum time to wait for space.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains full for the duration.

Definition at line 219 of file queue.hpp.

References idfxx::timeout, idfxx::queue< T >::try_send_to_front(), and idfxx::unwrap().

◆ send_to_front_from_isr()

template<typename T >
isr_send_result IRAM_ATTR idfxx::queue< T >::send_to_front_from_isr ( const T item)
inlinenoexcept

Sends an item to the front of the queue from ISR context.

Parameters
itemThe item to send.
Returns
Result containing success status and whether a context switch should be requested.
Note
Pass the yield field to idfxx::yield_from_isr() to perform the context switch if needed.
void IRAM_ATTR my_isr() {
auto [success, yield] = q->send_to_front_from_isr(urgent_value);
}

Definition at line 634 of file queue.hpp.

◆ send_to_front_until()

template<typename T >
void idfxx::queue< T >::send_to_front_until ( const T item,
const std::chrono::time_point< Clock, Duration > &  deadline 
)
inline

Sends an item to the front of the queue with a deadline.

Blocks until space is available or the deadline is reached. The item is placed at the front, so it will be the next item received.

Template Parameters
ClockThe clock type.
DurationThe duration type of the time point.
Parameters
itemThe item to send.
deadlineThe time point at which to stop waiting.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains full until the deadline.

Definition at line 238 of file queue.hpp.

References idfxx::queue< T >::try_send_to_front_until(), and idfxx::unwrap().

◆ send_until()

template<typename T >
void idfxx::queue< T >::send_until ( const T item,
const std::chrono::time_point< Clock, Duration > &  deadline 
)
inline

Sends an item to the back of the queue with a deadline.

Blocks until space is available or the deadline is reached.

Template Parameters
ClockThe clock type.
DurationThe duration type of the time point.
Parameters
itemThe item to send.
deadlineThe time point at which to stop waiting.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.
Exceptions
std::system_errorwith idfxx::errc::timeout if the queue remains full until the deadline.

Definition at line 188 of file queue.hpp.

References idfxx::queue< T >::try_send_until(), and idfxx::unwrap().

◆ size()

template<typename T >
size_t idfxx::queue< T >::size ( ) const
inlinenoexcept

Returns the number of items currently in the queue.

Returns
The number of items in the queue.

Definition at line 735 of file queue.hpp.

◆ try_peek() [1/2]

template<typename T >
result< T > idfxx::queue< T >::try_peek ( )
inline

Peeks at the front item in the queue without removing it, blocking indefinitely.

Blocks until an item is available. The item remains in the queue after peeking.

Returns
A copy of the front item, or an error.
Return values
timeoutThe queue remained empty.

Definition at line 529 of file queue.hpp.

Referenced by idfxx::queue< T >::peek(), and idfxx::queue< T >::peek().

◆ try_peek() [2/2]

template<typename T >
template<typename Rep , typename Period >
result< T > idfxx::queue< T >::try_peek ( const std::chrono::duration< Rep, Period > &  timeout)
inline

Peeks at the front item in the queue without removing it, with a timeout.

Blocks until an item is available or the timeout expires. The item remains in the queue after peeking.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
timeoutMaximum time to wait for an item.
Returns
A copy of the front item, or an error.
Return values
timeoutThe queue remained empty for the duration.

Definition at line 544 of file queue.hpp.

References idfxx::chrono::ticks(), and idfxx::timeout.

◆ try_peek_until()

template<typename T >
result< T > idfxx::queue< T >::try_peek_until ( const std::chrono::time_point< Clock, Duration > &  deadline)
inline

Peeks at the front item in the queue without removing it, with a deadline.

Blocks until an item is available or the deadline is reached. The item remains in the queue after peeking.

Template Parameters
ClockThe clock type.
DurationThe duration type of the time point.
Parameters
deadlineThe time point at which to stop waiting.
Returns
A copy of the front item, or an error.
Return values
timeoutThe queue remained empty until the deadline.

Definition at line 561 of file queue.hpp.

References idfxx::chrono::ticks().

Referenced by idfxx::queue< T >::peek_until().

◆ try_receive() [1/2]

template<typename T >
result< T > idfxx::queue< T >::try_receive ( )
inline

Receives an item from the queue, blocking indefinitely.

Blocks until an item is available.

Returns
The received item, or an error.
Return values
timeoutThe queue remained empty.

Definition at line 428 of file queue.hpp.

Referenced by idfxx::queue< T >::receive(), and idfxx::queue< T >::receive().

◆ try_receive() [2/2]

template<typename T >
template<typename Rep , typename Period >
result< T > idfxx::queue< T >::try_receive ( const std::chrono::duration< Rep, Period > &  timeout)
inline

Receives an item from the queue with a timeout.

Blocks until an item is available or the timeout expires.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
timeoutMaximum time to wait for an item.
Returns
The received item, or an error.
Return values
timeoutThe queue remained empty for the duration.

Definition at line 442 of file queue.hpp.

References idfxx::chrono::ticks(), and idfxx::timeout.

◆ try_receive_until()

template<typename T >
result< T > idfxx::queue< T >::try_receive_until ( const std::chrono::time_point< Clock, Duration > &  deadline)
inline

Receives an item from the queue with a deadline.

Blocks until an item is available or the deadline is reached.

Template Parameters
ClockThe clock type.
DurationThe duration type of the time point.
Parameters
deadlineThe time point at which to stop waiting.
Returns
The received item, or an error.
Return values
timeoutThe queue remained empty until the deadline.

Definition at line 458 of file queue.hpp.

References idfxx::chrono::ticks().

Referenced by idfxx::queue< T >::receive_until().

◆ try_send() [1/2]

template<typename T >
result< void > idfxx::queue< T >::try_send ( const T item)
inline

Sends an item to the back of the queue, blocking indefinitely.

Blocks until space is available in the queue.

Parameters
itemThe item to send.
Returns
Success, or an error.
Return values
timeoutThe queue remained full.

Definition at line 252 of file queue.hpp.

Referenced by idfxx::queue< T >::send(), and idfxx::queue< T >::send().

◆ try_send() [2/2]

template<typename T >
template<typename Rep , typename Period >
result< void > idfxx::queue< T >::try_send ( const T item,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Sends an item to the back of the queue with a timeout.

Blocks until space is available or the timeout expires.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
itemThe item to send.
timeoutMaximum time to wait for space.
Returns
Success, or an error.
Return values
timeoutThe queue remained full for the duration.

Definition at line 267 of file queue.hpp.

References idfxx::chrono::ticks(), and idfxx::timeout.

◆ try_send_to_front() [1/2]

template<typename T >
result< void > idfxx::queue< T >::try_send_to_front ( const T item)
inline

Sends an item to the front of the queue, blocking indefinitely.

Blocks until space is available in the queue. The item is placed at the front, so it will be the next item received.

Parameters
itemThe item to send.
Returns
Success, or an error.
Return values
timeoutThe queue remained full.

Definition at line 302 of file queue.hpp.

Referenced by idfxx::queue< T >::send_to_front(), and idfxx::queue< T >::send_to_front().

◆ try_send_to_front() [2/2]

template<typename T >
template<typename Rep , typename Period >
result< void > idfxx::queue< T >::try_send_to_front ( const T item,
const std::chrono::duration< Rep, Period > &  timeout 
)
inline

Sends an item to the front of the queue with a timeout.

Blocks until space is available or the timeout expires. The item is placed at the front, so it will be the next item received.

Template Parameters
RepThe representation type of the duration.
PeriodThe period type of the duration.
Parameters
itemThe item to send.
timeoutMaximum time to wait for space.
Returns
Success, or an error.
Return values
timeoutThe queue remained full for the duration.

Definition at line 318 of file queue.hpp.

References idfxx::chrono::ticks(), and idfxx::timeout.

◆ try_send_to_front_until()

template<typename T >
result< void > idfxx::queue< T >::try_send_to_front_until ( const T item,
const std::chrono::time_point< Clock, Duration > &  deadline 
)
inline

Sends an item to the front of the queue with a deadline.

Blocks until space is available or the deadline is reached. The item is placed at the front, so it will be the next item received.

Template Parameters
ClockThe clock type.
DurationThe duration type of the time point.
Parameters
itemThe item to send.
deadlineThe time point at which to stop waiting.
Returns
Success, or an error.
Return values
timeoutThe queue remained full until the deadline.

Definition at line 337 of file queue.hpp.

References idfxx::chrono::ticks().

Referenced by idfxx::queue< T >::send_to_front_until().

◆ try_send_until()

template<typename T >
result< void > idfxx::queue< T >::try_send_until ( const T item,
const std::chrono::time_point< Clock, Duration > &  deadline 
)
inline

Sends an item to the back of the queue with a deadline.

Blocks until space is available or the deadline is reached.

Template Parameters
ClockThe clock type.
DurationThe duration type of the time point.
Parameters
itemThe item to send.
deadlineThe time point at which to stop waiting.
Returns
Success, or an error.
Return values
timeoutThe queue remained full until the deadline.

Definition at line 284 of file queue.hpp.

References idfxx::chrono::ticks().

Referenced by idfxx::queue< T >::send_until().


The documentation for this class was generated from the following file: