Struct SegQueue
pub struct SegQueue<T> { /* private fields */ }
An unbounded multi-producer multi-consumer queue.
This queue is implemented as a linked list of segments, where each segment is a small buffer
that can hold a handful of elements. There is no limit to how many elements can be in the queue
at a time. However, since segments need to be dynamically allocated as elements get pushed,
this queue is somewhat slower than ArrayQueue.
Examples
use SegQueue;
let q = new;
q.push;
q.push;
assert_eq!;
assert_eq!;
assert!;
Implementations
impl<T> SegQueue<T>
const fn new() -> SegQueue<T>Creates a new unbounded queue.
Examples
use SegQueue; let q = new;fn push(&self, value: T)Pushes back an element to the tail.
Examples
use SegQueue; let q = new; q.push; q.push;fn push_mut(&mut self, value: T)Pushes an element to the queue with exclusive mutable access.
Avoids atomic operations and synchronization, assuming no other threads access the queue concurrently.
Examples
use SegQueue; let mut q = new; q.push_mut; q.push_mut;fn pop(&self) -> Option<T>Pops the head element from the queue.
If the queue is empty,
Noneis returned.Examples
use SegQueue; let q = new; q.push; q.push; assert_eq!; assert_eq!; assert!;fn pop_mut(&mut self) -> Option<T>Pops the head element from the queue using an exclusive reference.
Avoids atomic operations and synchronization, assuming no other threads access the queue concurrently.
If the queue is empty,
Noneis returned.Examples
use SegQueue; let mut q = new; q.push; q.push; assert_eq!; assert_eq!; assert!;fn is_empty(&self) -> boolReturns
trueif the queue is empty.Examples
use SegQueue; let q = new; assert!; q.push; assert!;fn len(&self) -> usizeReturns the number of elements in the queue.
Examples
use SegQueue; let q = new; assert_eq!; q.push; assert_eq!; q.push; assert_eq!;
Trait Implementations
impl<T> Debug for SegQueue<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T> Default for SegQueue<T>
fn default() -> SegQueue<T>
impl<T> Drop for SegQueue<T>
fn drop(&mut self)
impl<T> IntoIterator for SegQueue<T>
type Item = T;type IntoIter = IntoIter<T>;fn into_iter(self) -> Self::IntoIter
impl<T> RefUnwindSafe for SegQueue<T>
impl<T> UnwindSafe for SegQueue<T>
impl<T: Send> Send for SegQueue<T>
impl<T: Send> Sync for SegQueue<T>
Auto Trait Implementations
impl<T> !Freeze for SegQueue<T>
impl<T> Unpin for SegQueue<T>
where
CachePadded<Position<T>>: Unpin + Unpin,
PhantomData<T>: Unpin,
impl<T> UnsafeUnpin for SegQueue<T>
where
CachePadded<Position<T>>: UnsafeUnpin + UnsafeUnpin,
PhantomData<T>: UnsafeUnpin,
Blanket Implementations
impl<T> Any for SegQueue<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for SegQueue<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for SegQueue<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for SegQueue<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for SegQueue<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for SegQueue<T>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for SegQueue<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>