Struct caffe2_imports::SegQueue
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§
§impl<T> SegQueue<T>
impl<T> SegQueue<T>
pub 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();
pub fn push(&self, value: T)
pub fn push(&self, value: T)
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>
pub fn pop(&self) -> Option<T>
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());
Trait Implementations§
§impl<T> IntoIterator for SegQueue<T>
impl<T> IntoIterator for SegQueue<T>
impl<T> Send for SegQueue<T>where T: Send,
impl<T> Sync for SegQueue<T>where T: Send,
Auto Trait Implementations§
impl<T> RefUnwindSafe for SegQueue<T>where T: RefUnwindSafe,
impl<T> Unpin for SegQueue<T>where T: Unpin,
impl<T> !UnwindSafe for SegQueue<T>
Blanket Implementations§
source§impl<T, I> IntoPyDict for Iwhere
T: PyDictItem,
I: IntoIterator<Item = T>,
impl<T, I> IntoPyDict for Iwhere T: PyDictItem, I: IntoIterator<Item = T>,
source§fn into_py_dict(self, py: Python<'_>) -> &PyDict
fn into_py_dict(self, py: Python<'_>) -> &PyDict
Converts self into a
PyDict
object pointer. Whether pointer owned or borrowed
depends on implementation.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.