pub struct SegQueue<T> { /* private fields */ }
Expand description
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 crossbeam_queue::SegQueue;
let q = SegQueue::new();
q.push('a');
q.push('b');
assert_eq!(q.pop(), Some('a'));
assert_eq!(q.pop(), Some('b'));
assert!(q.pop().is_none());
Implementations§
Source§impl<T> SegQueue<T>
impl<T> SegQueue<T>
Sourcepub const fn new() -> SegQueue<T>
pub const fn new() -> SegQueue<T>
Creates a new unbounded queue.
§Examples
use crossbeam_queue::SegQueue;
let q = SegQueue::<i32>::new();
Sourcepub fn push(&self, value: T)
pub fn push(&self, value: T)
Pushes back an element to the tail.
§Examples
use crossbeam_queue::SegQueue;
let q = SegQueue::new();
q.push(10);
q.push(20);
Sourcepub fn pop(&self) -> Option<T>
pub fn pop(&self) -> Option<T>
Pops the head element from the queue.
If the queue is empty, None
is returned.
§Examples
use crossbeam_queue::SegQueue;
let q = SegQueue::new();
q.push(10);
q.push(20);
assert_eq!(q.pop(), Some(10));
assert_eq!(q.pop(), Some(20));
assert!(q.pop().is_none());
Trait Implementations§
Source§impl<T> IntoIterator for SegQueue<T>
impl<T> IntoIterator for SegQueue<T>
impl<T> RefUnwindSafe for SegQueue<T>
impl<T> Send for SegQueue<T>where
T: Send,
impl<T> Sync for SegQueue<T>where
T: Send,
impl<T> UnwindSafe for SegQueue<T>
Auto Trait Implementations§
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more