[][src]Struct crossbeam_deque::Stealer

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][]

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][+]

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

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][]

impl<T> ToOwned for T where
    T: Clone
[src][]

type Owned = T

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src][]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src][]

impl<T> Any for T where
    T: 'static + ?Sized
[src][]

impl<T> BorrowMut for T where
    T: ?Sized
[src][]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src][]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.