Skip to content

Commit

Permalink
Add a weight_max method as a nice shorthand. Fixes #13.
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomatsakis committed Jan 23, 2016
1 parent de1a9bc commit 54bd19a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/par_iter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//! The submodules of this module mostly just contain implementaton
//! details of little interest to an end-user.

use std::f64;
use std::ops::Fn;
use self::collect::collect_into;
use self::enumerate::Enumerate;
Expand Down Expand Up @@ -66,16 +67,27 @@ pub trait ParallelIterator {
/// parallel subtasks. 1.0 indicates something very cheap and
/// uniform, like copying a value out of an array, or computing `x
/// + 1`. If your tasks are either very expensive, or very
/// unpredictable, you are better off with higher values. Using
/// `f64::INFINITY` will cause the finest grained parallel
/// subtasks possible. Tuning this value should not affect
/// correctness but can improve (or hurt) performance.
/// unpredictable, you are better off with higher values. See also
/// `weight_max`, which is a convenient shorthand to force the
/// finest grained parallel execution posible. Tuning this value
/// should not affect correctness but can improve (or hurt)
/// performance.
fn weight(self, scale: f64) -> Weight<Self>
where Self: Sized
{
Weight::new(self, scale)
}

/// Shorthand for `self.weight(f64::INFINITY)`. This forces the
/// smallest granularity of parallel execution, which makes sense
/// when your parallel tasks are (potentially) very expensive to
/// execute.
fn weight_max(self) -> Weight<Self>
where Self: Sized
{
self.weight(f64::INFINITY)
}

/// Yields an index along with each item.
fn enumerate(self) -> Enumerate<Self>
where Self: Sized
Expand Down

0 comments on commit 54bd19a

Please sign in to comment.