parallel_task/lib.rs
1//! A super fast data parallelism library using Atomics to share data across threads and uniquely pull values
2//! from Collections such as Vec or HashMap. It follows a 'pull' approach and tries to reduce the time required
3//! for the thread to pick the next value. The key question was can the tine taken by thread to get the next job
4//! be kept minimal. This is achieved by using an AtomicIterator that generates a mutually exclusive usize value for each
5//! thread that corresponds to a unique stored value in the Collection.
6//! Hence, all types that implement the Fetch Trait (Vec and HashMap) can be consumed or passed by reference to run
7//! Map or ForEach functions on the same.
8
9//! The results show comparable performance to the popular Rayon library and in a number of cases improved performance as well.
10//! No study has been done to establish whether the results are significant.
11//!
12//!
13//!
14//! Add this crate using:
15//! ```
16//! cargo add parallel_task
17//! ```
18//!
19//! Code sample below:
20//!
21//! ```
22//! use parallel_task::prelude::*;
23//! let job = || {
24//!
25//! std::thread::sleep(Duration::from_nanos(10));
26//! (0..1_000).sum::<i32>()
27//! };
28//! let vec_jobs = (0..100_000).map(|_|job).collect::<Vec<_>>();
29
30//! Parallel Iter example
31//! let r1 = vec_jobs.parallel_iter().map(|func| func()).collect::<Vec<i32>>();
32
33//! // Into Parallel Iter that consumes the vec_jobs
34//! let r1 = vec_jobs.into_parallel_iter().map(|func| func()).collect::<Vec<i32>>();
35
36//! // Print all values using a for_each. This runs for_each concurrently on a Vec or HashMap
37//! r1.parallel_iter().for_each(|val| { print!("{} ",*val);});
38//! ```
39//!
40pub mod map;
41pub mod collector;
42pub mod worker_thread;
43pub mod errors;
44pub mod prelude;
45pub mod iterators;
46pub mod task_queue;
47pub mod for_each;
48pub mod for_each_mut;