Skip to content

Release 0.3.0:

Latest
Compare
Choose a tag to compare
@huonw huonw released this 13 Oct 04:12

This release brings two things: stability and safety.

Crossbeam is used for its scoped threads and scoping abstraction which
avoids the problems with destructors that affected the old
std::thread::scoped, however it does require passing an extra
parameter to most functions (the maps, since they return an iterator
handle that the user manipulates while the elements are being computed).

What was previously

let mut pool = simple_parallel::Pool::new(...);
let iter = unsafe { pool.map(some_iterator, &some_function) };

// ... use the `iter` ...

now needs to be surrounded at some level by a call to
crossbeam::scope, replacing the unsafe with the "Scope" parameter:

let mut pool = simple_parallel::Pool::new(...);
crossbeam::scope(|scope| {
    let iter = pool.map(scope, some_iterator, some_function);

    // ... use the `iter` ...
})

Note also that functions that previously required a &F (F: Fn(...) -> ...) parameter now just take F directly. This should be backwards
compatible, but allows nicer expressions: pool.map(..., |x| do something) instead of let f = |x| do something; pool.map(...., &f).