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