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

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());

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);

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> Clone for Stealer<T>
[src]

Creates another stealer.

Performs copy-assignment from source. Read more

impl<T: Send> Sync for Stealer<T>
[src]

impl<T> Debug for Stealer<T>
[src]

Formats the value using the given formatter. Read more

Blanket Implementations

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

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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

Performs the conversion.

impl<T> From for T
[src]

Performs the conversion.

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

🔬 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)

Performs the conversion.

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

Immutably borrows from an owned value. Read more

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

🔬 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)

Performs the conversion.

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

Mutably borrows from an owned value. Read more

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

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more