Struct swap_queue::Worker[][src]

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

A worker queue.

This is a queue that is owned by a single thread, but other threads may steal the entire underlying buffer. Typically one would use a single worker queue per thread.

Examples

use swap_queue::Worker;

let w = Worker::new();
let s = w.stealer();

w.push(1);
w.push(2);
w.push(3);

assert_eq!(s.take_queue(), vec![1, 2, 3]);
w.push(4);
w.push(5);
w.push(6);
assert_eq!(s.take_queue(), vec![4, 5, 6]);

Implementations

Creates a new Worker queue.

Tasks are pushed and the underlying buffer is swapped and converted back into a Vec<T> when taken by a stealer.

Examples

use swap_queue::Worker;

let w = Worker::<i32>::new();

Creates a stealer for this queue.

The returned stealer can be shared among threads and cloned.

Examples

use swap_queue::Worker;

let w = Worker::<i32>::new();
let s = w.stealer();

Push a task to the queue and returns the index written to

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.