work_steal_queue/
lib.rs

1//! Suppose a thread in a work-stealing scheduler is idle and looking for the next task to run. To
2//! find an available task, it might do the following:
3//!
4//! 1. Try popping one task from the local worker queue.
5//! 2. Try popping and stealing tasks from another local worker queue.
6//! 3. Try popping and stealing a batch of tasks from the global injector queue.
7//!
8//! An implementation of this work-stealing strategy:
9//!
10//! # Examples
11//!
12//! ```
13//! use work_steal_queue::WorkStealQueue;
14//!
15//! let queue = WorkStealQueue::new(2, 64);
16//! queue.push(6);
17//! queue.push(7);
18//!
19//! let local0 = queue.local_queue();
20//! local0.push_back(2);
21//! local0.push_back(3);
22//! local0.push_back(4);
23//! local0.push_back(5);
24//!
25//! let local1 = queue.local_queue();
26//! local1.push_back(0);
27//! local1.push_back(1);
28//! for i in 0..8 {
29//!     assert_eq!(local1.pop_front(), Some(i));
30//! }
31//! assert_eq!(local0.pop_front(), None);
32//! assert_eq!(local1.pop_front(), None);
33//! assert_eq!(queue.pop(), None);
34//! ```
35//!
36
37pub use rand::*;
38pub use work_steal::*;
39
40pub mod rand;
41
42pub mod work_steal;