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>
impl<T> Queue<T>
sourcepub(super) fn new() -> Self
pub(super) fn new() -> Self
Creates a new queue that is safe to share among multiple producers and one consumer.
sourcepub(super) unsafe fn pop(&self) -> PopResult<T>
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.