Module iterator

Module iterator 

Source
Expand description

AtomicIterator is a trait implementd on ParallelIterator and IntoParallelIterator which are both available for types implementing the Fetch trait. AtomicIterator and Fetch traits together help in establishing a 1 to 1 relationship with a value stored in the Collection to a usize value. Further using a counter of AtomicUsize type which is indivisible it ensures that each thread does not get the same value as another thread. Allowing threads to access values in the Collection in a mutually exclusive manner.

Structs§

IntoParallelIterator
IntoParallelIterator is comparable to IntoIter, but is set up for the AtomicIterator. Collection keys are only stored in the case of types like HashMap where the keys collection is used to establish a unique 1 to 1 relationship with a usize value from atomic_counter.
ParallelIterator
ParallelIterator is comparable to Iter, but is set up for the AtomicIterator. Collection keys are only stored in the case of types like HashMap where the keys collection is used to establish a unique 1 to 1 relationship with a usize value from atomic_counter.
ShareableAtomicIter
ShareableAtomicIter enables Vec and HashMap that implement the Fetch trait to easily distributed across threads. Values can be safely accessed without any risk of overlaps. Thus allowing you to design how you wish to process these collections across your threads

Traits§

AtomicIterator
AtomicIterator depends on the ability to create a 1 to 1 association with a usize value less than len and a stored value within the type. For instance in vec![1,2,3] a usize value of 1 would give 2. In HashMap {(1,“A”), (2,“B”), (3,“B”) } where collection of keys are [1,2,3], the usize 1 will be mapped to (2,“B”) based on its position in the collection of keys. AtomicUsize and fetch_add function is used to ensure each thread gets an independent usize value that it may use to fetch a unique value from the target pool.
ParallelIter