Struct coco::deque::Worker [] [src]

pub struct Worker<T> { /* fields omitted */ }

Worker side of a work-stealing deque.

There is only one worker per deque.

Methods

impl<T> Worker<T>
[src]

[src]

Returns the number of elements in the deque.

If used concurrently with other operations, the returned number is just an estimate.

Examples

use coco::deque;

let (w, _) = deque::new();
for i in 0..30 {
    w.push(i);
}
assert_eq!(w.len(), 30);

[src]

Pushes an element onto the bottom of the deque.

Examples

use coco::deque;

let (w, _) = deque::new();
w.push(1);
w.push(2);

[src]

Pops an element from the bottom of the deque.

Examples

use coco::deque;

let (w, _) = deque::new();
w.push(1);
w.push(2);

assert_eq!(w.pop(), Some(2));
assert_eq!(w.pop(), Some(1));
assert_eq!(w.pop(), None);

[src]

Steals an element from the top of the deque.

Examples

use coco::deque;

let (w, _) = deque::new();
w.push(1);
w.push(2);

assert_eq!(w.steal(), Some(1));
assert_eq!(w.steal(), Some(2));
assert_eq!(w.steal(), None);

[src]

Steals an element from the top of the deque, but may sometimes spuriously fail.

If another concurrent operation gets in the way when stealing data, this method will return immediately with Steal::Inconsistent instead of retrying.

Examples

use coco::deque::{self, Steal};

let (w, _) = deque::new();
w.push(1);
assert_eq!(w.steal_weak(), Steal::Data(1));

Trait Implementations

impl<T: Send> Send for Worker<T>
[src]

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

[src]

Formats the value using the given formatter.