open_coroutine_queue/lib.rs
1#![deny(
2 // The following are allowed by default lints according to
3 // https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html
4 anonymous_parameters,
5 bare_trait_objects,
6 box_pointers,
7 elided_lifetimes_in_paths,
8 missing_copy_implementations,
9 missing_debug_implementations,
10 missing_docs,
11 single_use_lifetimes,
12 trivial_casts,
13 trivial_numeric_casts,
14 unreachable_pub,
15 unsafe_code,
16 unstable_features,
17 unused_extern_crates,
18 unused_import_braces,
19 unused_qualifications,
20 unused_results,
21 variant_size_differences,
22 warnings, // treat all wanings as errors
23
24 clippy::all,
25 // clippy::restriction,
26 clippy::pedantic,
27 // clippy::nursery, // It's still under development
28 clippy::cargo,
29)]
30#![allow(
31 // Some explicitly allowed Clippy lints, must have clear reason to allow
32 clippy::blanket_clippy_restriction_lints, // allow clippy::restriction
33 clippy::implicit_return, // actually omitting the return keyword is idiomatic Rust code
34 clippy::module_name_repetitions, // repeation of module name in a struct name is not big deal
35 clippy::multiple_crate_versions, // multi-version dependency crates is not able to fix
36 clippy::panic_in_result_fn,
37 clippy::shadow_same, // Not too much bad
38 clippy::shadow_reuse, // Not too much bad
39 clippy::exhaustive_enums,
40 clippy::exhaustive_structs,
41 clippy::indexing_slicing,
42 clippy::wildcard_imports,
43 clippy::separated_literal_suffix, // conflicts with clippy::unseparated_literal_suffix
44)]
45
46//! Suppose a thread in a work-stealing scheduler is idle and looking for the next task to run. To
47//! find an available task, it might do the following:
48//!
49//! 1. Try popping one task from the local worker queue.
50//! 2. Try popping and stealing tasks from another local worker queue.
51//! 3. Try popping and stealing a batch of tasks from the global injector queue.
52//!
53//! An implementation of this work-stealing strategy:
54//!
55//! # Examples
56//!
57//! ```
58//! use open_coroutine_queue::WorkStealQueue;
59//!
60//! let queue = WorkStealQueue::new(2, 64);
61//! queue.push(6);
62//! queue.push(7);
63//!
64//! let local0 = queue.local_queue();
65//! local0.push_back(2);
66//! local0.push_back(3);
67//! local0.push_back(4);
68//! local0.push_back(5);
69//!
70//! let local1 = queue.local_queue();
71//! local1.push_back(0);
72//! local1.push_back(1);
73//! for i in 0..8 {
74//! assert_eq!(local1.pop_front(), Some(i));
75//! }
76//! assert_eq!(local0.pop_front(), None);
77//! assert_eq!(local1.pop_front(), None);
78//! assert_eq!(queue.pop(), None);
79//! ```
80//!
81
82pub use rand::*;
83pub use work_steal::*;
84
85/// rand impl for work steal queue
86#[allow(missing_docs)]
87pub mod rand;
88
89/// work steal queue impl
90pub mod work_steal;