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(std::time::Duration::from_nanos(10));
26//! (0..1_000).sum::<i32>()
27//! };
28//! let vec_jobs = (0..100_000).map(|_|job).collect::<Vec<_>>();
29//! // Parallel Iter example
30//! let r1 = vec_jobs.parallel_iter().map(|func| func()).collect::<Vec<i32>>();
31//! // Into Parallel Iter that consumes the vec_jobs
32//! let r1 = vec_jobs.into_parallel_iter().map(|func| func()).collect::<Vec<i32>>();
33//! // Print all values using a for_each. This runs for_each concurrently on a Vec or HashMap
34//! r1.parallel_iter().for_each(|val| { print!("{} ",*val);});
35//! ```
36//!
37pub mod map;
38pub mod collector;
39pub mod worker_thread;
40pub mod errors;
41pub mod prelude;
42pub mod iterators;
43pub mod task_queue;
44pub mod for_each;
45pub mod for_each_mut;