pub struct Queue<T: Copy + Sized> { /* private fields */ }Expand description
A type-safe message queue for communicating between tasks within an application.
The type T must be Copy and Sized to be sent over the queue, as the
underlying OSAL API works with raw byte copies.
Implementations§
Source§impl<T: Copy + Sized> Queue<T>
impl<T: Copy + Sized> Queue<T>
Sourcepub fn new(name: &str, depth: usize) -> Result<Self>
pub fn new(name: &str, depth: usize) -> Result<Self>
Creates a new message queue.
§Arguments
name: A unique string to identify the queue.depth: The maximum number of messages the queue can hold.
Sourcepub fn put(&self, message: &T) -> Result<()>
pub fn put(&self, message: &T) -> Result<()>
Puts a message onto the queue.
This operation is non-blocking. If the queue is full, an error is returned.
§Arguments
message: A reference to the message data to send.
Sourcepub fn get(&self, timeout_ms: i32) -> Result<T>
pub fn get(&self, timeout_ms: i32) -> Result<T>
Retrieves a message from the queue.
This operation can block until a message is available, depending on the timeout.
§Arguments
timeout_ms: Timeout in milliseconds. Can be a positive value,ffi::OS_CHECK(0) for a non-blocking poll, orffi::OS_PEND(-1) to block indefinitely.
Sourcepub fn get_id_by_name(name: &str) -> Result<OsalId>
pub fn get_id_by_name(name: &str) -> Result<OsalId>
Finds an existing queue ID by its name.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Queue<T>
impl<T> RefUnwindSafe for Queue<T>where
T: RefUnwindSafe,
impl<T> Send for Queue<T>where
T: Send,
impl<T> Sync for Queue<T>where
T: Sync,
impl<T> Unpin for Queue<T>where
T: Unpin,
impl<T> UnsafeUnpin for Queue<T>
impl<T> UnwindSafe for Queue<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more