pub struct SegQueue<T> { /* fields omitted */ }
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
.
use crossbeam_queue::{PopError, SegQueue};
let q = SegQueue::new();
q.push('a');
q.push('b');
assert_eq!(q.pop(), Ok('a'));
assert_eq!(q.pop(), Ok('b'));
assert_eq!(q.pop(), Err(PopError));
Creates a new unbounded queue.
use crossbeam_queue::SegQueue;
let q = SegQueue::<i32>::new();
Pushes an element into the queue.
use crossbeam_queue::SegQueue;
let q = SegQueue::new();
q.push(10);
q.push(20);
Pops an element from the queue.
If the queue is empty, an error is returned.
use crossbeam_queue::{PopError, SegQueue};
let q = SegQueue::new();
q.push(10);
assert_eq!(q.pop(), Ok(10));
assert_eq!(q.pop(), Err(PopError));
Returns true
if the queue is empty.
use crossbeam_queue::SegQueue;
let q = SegQueue::new();
assert!(q.is_empty());
q.push(1);
assert!(!q.is_empty());
Returns the number of elements in the queue.
use crossbeam_queue::{SegQueue, PopError};
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);
Returns the "default value" for a type. Read more
Executes the destructor for this type. Read more
Formats the value using the given formatter. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)