[−][src]Struct crossbeam_deque::Stealer
A stealer that steals elements from the top of a deque.
The only operation a stealer can do that manipulates the deque is steal
.
Stealers can be cloned in order to create more of them. They also implement Send
and Sync
so they can be easily shared among multiple threads.
Methods
impl<T> Stealer<T>
[src][−]
pub fn is_empty(&self) -> bool
[src][−]
Returns true
if the deque is empty.
Examples
use crossbeam_deque::Deque; let d = Deque::new(); d.push("foo"); let s = d.stealer(); assert!(!d.is_empty()); s.steal(); assert!(d.is_empty());
pub fn len(&self) -> usize
[src][−]
Returns the number of elements in the deque.
Examples
use crossbeam_deque::Deque; let d = Deque::new(); let s = d.stealer(); d.push('a'); d.push('b'); d.push('c'); assert_eq!(s.len(), 3);
pub fn steal(&self) -> Steal<T>
[src][−]
Steals an element from the top of the deque.
Unlike most methods in concurrent data structures, if another operation gets in the way
while attempting to steal data, this method will return immediately with Steal::Retry
instead of retrying.
This method will not attempt to resize the internal buffer.
Examples
use crossbeam_deque::{Deque, Steal}; let d = Deque::new(); let s = d.stealer(); d.push(1); d.push(2); // Attempt to steal an element, but keep retrying if we get `Retry`. loop { match d.steal() { Steal::Empty => panic!("should steal something"), Steal::Data(data) => { assert_eq!(data, 1); break; } Steal::Retry => {} } }
Trait Implementations
impl<T: Send> Sync for Stealer<T>
[src]
impl<T> Clone for Stealer<T>
[src][+]
impl<T: Send> Send for Stealer<T>
[src]
impl<T> Debug for Stealer<T>
[src][+]
Blanket Implementations
impl<T> From for T
[src][−]
impl<T, U> Into for T where
U: From<T>,
[src][−]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src][−]
T: Clone,
impl<T, U> TryFrom for T where
U: Into<T>,
[src][−]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src][−]
impl<T> Borrow for T where
T: ?Sized,
[src][−]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src][−]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src][−]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src][−]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src][−]
U: TryFrom<T>,