Struct swap_queue::Worker[][src]

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

A thread-owned worker queue that writes to a swappable buffer using atomic slotting

Examples

use swap_queue::Worker;

let w = Worker::new();
let s = w.push(1).unwrap();
w.push(2);
w.push(3);
assert_eq!(s.take_blocking(), vec![1, 2, 3]);

let s = w.push(4).unwrap();
w.push(5);
w.push(6);
let batch: Vec<_> = s.into();
assert_eq!(batch, 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();

Push a task to the queue and returns a Stealer if empty

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. 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.