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]

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

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

[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`.
let stolen = loop {
    match s.steal() {
        Steal::Empty => break None,
        Steal::Data(data) => break Some(data),
        Steal::Retry => {}
    }
};
assert_eq!(stolen, Some(1));

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]

[src]

Creates another stealer.

1.0.0
[src]

Performs copy-assignment from source. Read more

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

[src]

Formats the value using the given formatter. Read more