Struct esp_idf_hal::task::queue::Queue
source · pub struct Queue<T> { /* private fields */ }
Expand description
Thin wrapper on top of the FreeRTOS queue.
This may be preferable over a Rust channel in cases where an ISR needs to send or receive data as it is safe to use in ISR contexts.
Implementations§
source§impl<T> Queue<T>where
T: Copy,
impl<T> Queue<T>where
T: Copy,
sourcepub unsafe fn new_borrowed(ptr: QueueHandle_t) -> Self
pub unsafe fn new_borrowed(ptr: QueueHandle_t) -> Self
Create a new queue which is not deleted on Drop
, but owned by somebody else.
§Safety
Care must be taken that the queue is valid for the constructed lifetime.
source#[link_section = "iram1.queue_as_raw"]pub fn as_raw(&self) -> QueueHandle_t
#[link_section = "iram1.queue_as_raw"]pub fn as_raw(&self) -> QueueHandle_t
Retrieves the underlying FreeRTOS handle.
source#[link_section = "iram1.queue_send_back"]pub fn send_back(&self, item: T, timeout: TickType_t) -> Result<bool, EspError>
#[link_section = "iram1.queue_send_back"]pub fn send_back(&self, item: T, timeout: TickType_t) -> Result<bool, EspError>
Copy item to back of queue, blocking for timeout
ticks if full.
§ISR safety
This function is safe to call in ISR contexts.
§Parameters
item
the item to push onto the back of the queuetimeout
specifies how long to block. Ignored in ISR context.
§Returns
Will return an error if queue is full.
If this function is executed in an ISR context,
it will return true if a higher priority task was awoken.
In non-ISR contexts, the function will always return false
.
In this case the interrupt should call crate::task::do_yield
.
source#[link_section = "iram1.queue_send_front"]pub fn send_front(&self, item: T, timeout: TickType_t) -> Result<bool, EspError>
#[link_section = "iram1.queue_send_front"]pub fn send_front(&self, item: T, timeout: TickType_t) -> Result<bool, EspError>
Copy item to front of queue, blocking for timeout
ticks if full.
This can be used for hight priority messages which should be processed
sooner.
§ISR safety
This function is safe to call in ISR contexts.
§Parameters
item
the item to push to front of the queuetimeout
specifies how long to block. Ignored in ISR context.
§Returns
Will return an error if queue is full.
If this function is executed in an ISR context,
it will return true if a higher priority task was awoken.
In non-ISR contexts, the function will always return false
.
In this case the interrupt should call crate::task::do_yield
.
source#[link_section = "iram1.queue_recv_front"]pub fn recv_front(&self, timeout: TickType_t) -> Option<(T, bool)>
#[link_section = "iram1.queue_recv_front"]pub fn recv_front(&self, timeout: TickType_t) -> Option<(T, bool)>
Receive a message from the queue and remove it.
§ISR safety
This function is safe to use in ISR contexts
§Parameters
timeout
specifies how long to block. Ignored in ISR contexts.
§Returns
None
if no message could be received in timeSome((message, higher_priority_task_awoken))
otherwise
The boolean is used for ISRs and indicates if a higher priority task was awoken.
In this case the interrupt should call crate::task::do_yield
.
In non-ISR contexts, the function will always return false
.
source#[link_section = "iram1.queue_peek_front"]pub fn peek_front(&self, timeout: TickType_t) -> Option<T>
#[link_section = "iram1.queue_peek_front"]pub fn peek_front(&self, timeout: TickType_t) -> Option<T>
Copy the first message from the queue without removing it.
§ISR safety
This function is safe to use in ISR contexts
§Parameters
timeout
specifies how long to block. Ignored in ISR contexts.
§Returns
None
if no message could be received in timeSome(message)
otherwise
This function does not return a boolean to indicate if a higher priority task was awoken since we don’t free up space in the queue and thus cannot unblock anyone.