Module crossbeam::sync::chase_lev [] [src]

A lock-free concurrent work-stealing deque

This module contains a hybrid implementation of the Chase-Lev work stealing deque described in "Dynamic Circular Work-Stealing Deque" and the improved version described in "Correct and Efficient Work-Stealing for Weak Memory Models". The implementation is heavily based on the pseudocode found in the papers.

Example

use crossbeam::sync::chase_lev;
let (mut worker, stealer) = chase_lev::deque();

// Only the worker may push/try_pop
worker.push(1);
worker.try_pop();

// Stealers take data from the other end of the deque
worker.push(1);
stealer.steal();

// Stealers can be cloned to have many stealers stealing in parallel
worker.push(1);
let stealer2 = stealer.clone();
stealer2.steal();

Structs

Stealer

The stealing half of the work-stealing deque. Stealers have access to the opposite end of the deque from the worker, and they only have access to the steal method.

Worker

Worker half of the work-stealing deque. This worker has exclusive access to one side of the deque, and uses push and try_pop method to manipulate it.

Enums

Steal

When stealing some data, this is an enumeration of the possible outcomes.

Functions

deque

Creates a new empty deque