Struct futures_channel::mpsc::queue::Queue

source ·
pub(super) struct Queue<T> {
    head: AtomicPtr<Node<T>>,
    tail: UnsafeCell<*mut Node<T>>,
}
Expand description

The multi-producer single-consumer structure. This is not cloneable, but it may be safely shared so long as it is guaranteed that there is only one popper at a time (many pushers are allowed).

Fields§

§head: AtomicPtr<Node<T>>§tail: UnsafeCell<*mut Node<T>>

Implementations§

source§

impl<T> Queue<T>

source

pub(super) fn new() -> Self

Creates a new queue that is safe to share among multiple producers and one consumer.

source

pub(super) fn push(&self, t: T)

Pushes a new value onto this queue.

source

pub(super) unsafe fn pop(&self) -> PopResult<T>

Pops some data from this queue.

Note that the current implementation means that this function cannot return Option<T>. It is possible for this queue to be in an inconsistent state where many pushes have succeeded and completely finished, but pops cannot return Some(t). This inconsistent state happens when a pusher is preempted at an inopportune moment.

This inconsistent state means that this queue does indeed have data, but it does not currently have access to it at this time.

This function is unsafe because only one thread can call it at a time.

source

pub(super) unsafe fn pop_spin(&self) -> Option<T>

Pop an element similarly to pop function, but spin-wait on inconsistent queue state instead of returning Inconsistent.

This function is unsafe because only one thread can call it at a time.

Trait Implementations§

source§

impl<T> Drop for Queue<T>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T: Send> Send for Queue<T>

source§

impl<T: Send> Sync for Queue<T>

Auto Trait Implementations§

§

impl<T> !Freeze for Queue<T>

§

impl<T> !RefUnwindSafe for Queue<T>

§

impl<T> Unpin for Queue<T>

§

impl<T> UnwindSafe for Queue<T>
where T: RefUnwindSafe,

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.