zephyr::sys::queue

Struct Queue

Source
pub struct Queue(/* private fields */);
Expand description

A wrapper around a Zephyr k_queue object.

Implementations§

Source§

impl Queue

Source

pub const fn new() -> Queue

Create a new Queue, dynamically allocated.

This Queue can only be used from system threads.

Note: When a Queue is dropped, any messages that have been added to the queue will be leaked.

Source

pub unsafe fn send(&self, data: *mut c_void)

Append an element to the end of a queue.

This adds an element to the given Queue. Zephyr requires the first word of this message to be available for the OS to enqueue the message. See Message for details on how this can be used safely.

§Safety

Zephyr has specific requirements on the memory given in data, which can be summarized as:

  • The memory must remain valid until after the data is returned, via recv.
  • The first usize in the pointed data will be mutated by Zephyr to manage structures.
  • This first field must not be modified by any code while the message is enqueued.

These are easiest to satisfy by ensuring the message is Boxed, and owned by the queue system.

Source

pub unsafe fn recv<T>(&self, timeout: T) -> *mut c_void
where T: Into<Timeout>,

Get an element from a queue.

This routine removes the first data item from the Queue. The timeout value can be Forever to block until there is a message, NoWait to check and immediately return if there is no message, or a Duration to indicate a specific timeout.

§Safety

Once an item is received from a queue, ownership is returned to the caller, and Zephyr no longer depends on it not being freed, or the first usize field being for its use.

Trait Implementations§

Source§

impl Debug for Queue

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Send for Queue

Source§

impl Sync for Queue

Auto Trait Implementations§

§

impl !Freeze for Queue

§

impl !RefUnwindSafe for Queue

§

impl Unpin for Queue

§

impl UnwindSafe for Queue

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.