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, memory_type mem_type=memory_type::internal)
 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 &&)=delete
 
queueoperator= (queue &&)=delete
 
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< void > try_send (const T &item)
 Sends an item to the back of the queue, blocking indefinitely.
 
template<typename Rep , typename Period >
result< void > try_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< void > try_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< void > try_send_to_front (const T &item)
 Sends an item to the front of the queue, blocking indefinitely.
 
template<typename Rep , typename Period >
result< void > try_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< void > try_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.
 
void try_overwrite (const T &item) noexcept
 Overwrites the last item in the queue, or sends if the queue is not full.
 
receive ()
 Receives an item from the queue, blocking indefinitely.
 
template<typename Rep , typename Period >
receive (const std::chrono::duration< Rep, Period > &timeout)
 Receives an item from the queue with a timeout.
 
template<typename Clock , typename Duration >
receive_until (const std::chrono::time_point< Clock, Duration > &deadline)
 Receives an item from the queue with a deadline.
 
result< T > try_receive ()
 Receives an item from the queue, blocking indefinitely.
 
template<typename Rep , typename Period >
result< T > try_receive (const std::chrono::duration< Rep, Period > &timeout)
 Receives an item from the queue with a timeout.
 
template<typename Clock , typename Duration >
result< T > try_receive_until (const std::chrono::time_point< Clock, Duration > &deadline)
 Receives an item from the queue with a deadline.
 
peek ()
 Peeks at the front item in the queue without removing it, blocking indefinitely.
 
template<typename Rep , typename Period >
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 >
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< T > try_peek ()
 Peeks at the front item in the queue without removing it, blocking indefinitely.
 
template<typename Rep , typename Period >
result< T > try_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< T > try_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< std::unique_ptr< queue > > make (size_t length, memory_type mem_type=memory_type::internal)
 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.

Queues are non-copyable and non-movable. Use the factory method make() for result-based construction or the throwing constructor when exceptions are enabled.

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);
Type-safe inter-task message queue.
Definition queue.hpp:67

Definition at line 67 of file queue.hpp.

Constructor & Destructor Documentation

◆ queue() [1/3]

template<typename T >
idfxx::queue< T >::queue ( size_t  length,
memory_type  mem_type = memory_type::internal 
)
inlineexplicit

Creates a queue with the specified capacity.

Parameters
lengthMaximum number of items the queue can hold.
mem_typeMemory region 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::system_errorwith idfxx::errc::no_mem if memory allocation fails.

Definition at line 79 of file queue.hpp.

References idfxx::invalid_arg, and idfxx::no_mem.

◆ ~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 118 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 > &&  )
delete

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 728 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 735 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 742 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 752 of file queue.hpp.

◆ make()

template<typename T >
static result< std::unique_ptr< queue > > idfxx::queue< T >::make ( size_t  length,
memory_type  mem_type = memory_type::internal 
)
inlinestatic

Creates a queue with the specified capacity.

Parameters
lengthMaximum number of items the queue can hold.
mem_typeMemory region for queue storage allocation.
Returns
The new queue, or an error.
Return values
invalid_arglength is 0.
no_memMemory allocation failed.

Definition at line 101 of file queue.hpp.

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

◆ 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 > &&  )
delete

◆ 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.
Note
Only available when CONFIG_COMPILER_CXX_EXCEPTIONS is enabled.

Definition at line 352 of file queue.hpp.

References idfxx::queue< T >::try_overwrite().

◆ 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 657 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 481 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 498 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 704 of file queue.hpp.

◆ peek_until()

template<typename T >
template<typename Clock , typename Duration >
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 517 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 382 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 398 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 682 of file queue.hpp.

◆ receive_until()

template<typename T >
template<typename Clock , typename Duration >
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 416 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 759 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 144 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 160 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 609 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 192 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 209 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 632 of file queue.hpp.

◆ send_to_front_until()

template<typename T >
template<typename Clock , typename Duration >
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 228 of file queue.hpp.

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

◆ send_until()

template<typename T >
template<typename Clock , typename Duration >
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 178 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 721 of file queue.hpp.

◆ try_overwrite()

template<typename T >
void idfxx::queue< T >::try_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 366 of file queue.hpp.

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

◆ 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 530 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 545 of file queue.hpp.

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

◆ try_peek_until()

template<typename T >
template<typename Clock , typename Duration >
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 562 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 429 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 443 of file queue.hpp.

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

◆ try_receive_until()

template<typename T >
template<typename Clock , typename Duration >
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 459 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 242 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 257 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 292 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 308 of file queue.hpp.

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

◆ try_send_to_front_until()

template<typename T >
template<typename Clock , typename Duration >
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 327 of file queue.hpp.

References idfxx::chrono::ticks().

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

◆ try_send_until()

template<typename T >
template<typename Clock , typename Duration >
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 274 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: