Skip to content

Commit

Permalink
Merge pull request rayon-rs#57 from nikomatsakis/this-and-that
Browse files Browse the repository at this point in the history
Add a few odds and ends
  • Loading branch information
nikomatsakis committed Feb 20, 2016
2 parents f8d7fe1 + 3ea4d81 commit 8b0bedb
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 5 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ script:
- |
[ $TRAVIS_RUST_VERSION != nightly ] ||
cargo test --features nightly
- cd demo/quicksort
- cargo build
- cd demo/quicksort && cargo build && cd ../../
- |
[ $TRAVIS_RUST_VERSION != nightly ] ||
( cd demo/nbody && cargo run --release -- bench && cd ../../ )
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rayon"
version = "0.2.0"
version = "0.3.0"
authors = ["Niko Matsakis <niko@alum.mit.edu>"]
description = "Simple work-stealing parallelism for Rust"
license = "Apache-2.0/MIT"
Expand Down
11 changes: 9 additions & 2 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# Release 0.3 (not yet released)

- Expanded `par_iter` API now available
- Expanded `par_iter` APIs now available:
- `into_par_iter` is now supported on vectors (taking ownership of the elements)
- Panic handling is much improved:
- if you use the Nightly feature, experimental panic recovery is available
- otherwise, panics propagate out and poision the workpool
- New `Configuration` object to control number of threads and other details
- New demos and benchmarks
- try `cargo run --release -- visualize` in `demo/nbody` :)
- Note: a nightly compiler is required for this demo due to the
use of the `+=` syntax

Thanks to @cuviper and @willi-kappler for their contributions!
Thanks to @bjz, @cuviper, @Amanieu, and @willi-kappler for their contributions!

# Release 0.2 and earlier

Expand Down
9 changes: 9 additions & 0 deletions src/par_iter/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ impl<'data, T: Sync + 'data> IntoParallelIterator for &'data [T] {
}
}

impl<'data, T: Sync + 'data> IntoParallelIterator for &'data Vec<T> {
type Item = &'data T;
type Iter = SliceIter<'data, T>;

fn into_par_iter(self) -> Self::Iter {
SliceIter { slice: self }
}
}

impl<'data, T: Sync + 'data> IntoParallelRefIterator<'data> for [T] {
type Item = T;
type Iter = SliceIter<'data, T>;
Expand Down
9 changes: 9 additions & 0 deletions src/par_iter/slice_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ impl<'data, T: Send + 'data> IntoParallelIterator for &'data mut [T] {
}
}

impl<'data, T: Send + 'data> IntoParallelIterator for &'data mut Vec<T> {
type Item = &'data mut T;
type Iter = SliceIterMut<'data, T>;

fn into_par_iter(self) -> Self::Iter {
SliceIterMut { slice: self }
}
}

impl<'data, T: Send + 'data> IntoParallelRefMutIterator<'data> for [T] {
type Item = T;
type Iter = SliceIterMut<'data, T>;
Expand Down
24 changes: 24 additions & 0 deletions src/par_iter/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,30 @@ pub fn check_zip() {
assert!(a.iter().all(|&x| x == a.len() - 1));
}

#[test]
pub fn check_zip_into_par_iter() {
let mut a: Vec<usize> = (0..1024).rev().collect();
let b: Vec<usize> = (0..1024).collect();

a.par_iter_mut()
.zip(&b) // here we rely on &b iterating over &usize
.for_each(|(a, &b)| *a += b);

assert!(a.iter().all(|&x| x == a.len() - 1));
}

#[test]
pub fn check_zip_into_mut_par_iter() {
let a: Vec<usize> = (0..1024).rev().collect();
let mut b: Vec<usize> = (0..1024).collect();

a.par_iter()
.zip(&mut b)
.for_each(|(&a, b)| *b += a);

assert!(b.iter().all(|&x| x == b.len() - 1));
}

#[test]
pub fn check_zip_range() {
let mut a: Vec<usize> = (0..1024).rev().collect();
Expand Down

0 comments on commit 8b0bedb

Please sign in to comment.