Struct crossbeam_queue::SegQueue [−][src]
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
impl<T> SegQueue<T>
[src]
pub const fn new() -> SegQueue<T>
[src]
Creates a new unbounded queue.
Examples
use crossbeam_queue::SegQueue; let q = SegQueue::<i32>::new();
pub fn push(&self, value: T)
[src]
Pushes an element into the queue.
Examples
use crossbeam_queue::SegQueue; let q = SegQueue::new(); q.push(10); q.push(20);
pub fn pop(&self) -> Option<T>
[src]
Pops an element from the queue.
If the queue is empty, None
is returned.
Examples
use crossbeam_queue::SegQueue; let q = SegQueue::new(); q.push(10); assert_eq!(q.pop(), Some(10)); assert!(q.pop().is_none());
pub fn is_empty(&self) -> bool
[src]
Returns true
if the queue is empty.
Examples
use crossbeam_queue::SegQueue; let q = SegQueue::new(); assert!(q.is_empty()); q.push(1); assert!(!q.is_empty());
pub fn len(&self) -> usize
[src]
Returns the number of elements in the queue.
Examples
use crossbeam_queue::SegQueue; let q = SegQueue::new(); assert_eq!(q.len(), 0); q.push(10); assert_eq!(q.len(), 1); q.push(20); assert_eq!(q.len(), 2);
Trait Implementations
impl<T> Debug for SegQueue<T>
[src]
impl<T> Default for SegQueue<T>
[src]
impl<T> Drop for SegQueue<T>
[src]
impl<T: Send> Send for SegQueue<T>
[src]
impl<T: Send> Sync for SegQueue<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for SegQueue<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Unpin for SegQueue<T> where
T: Unpin,
T: Unpin,
impl<T> !UnwindSafe for SegQueue<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,