Struct crossbeam_deque::Stealer
[−]
[src]
pub struct Stealer<T> { /* fields omitted */ }
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]
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());
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);
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> Send for Stealer<T>
[src]
impl<T: Send> Sync for Stealer<T>
[src]
impl<T> Clone for Stealer<T>
[src]
fn clone(&self) -> Stealer<T>
[src]
Creates another stealer.
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more