Closed
Description
Info located at: http://doc.rust-lang.org/book/tasks.html
// Create a vector of ports, one for each child thread
let rxs = Vec::from_fn(3, |init_val| {
let (tx, rx) = channel();
spawn(move || {
tx.send(some_expensive_computation(init_val));
});
rx
});
// Wait on each port, accumulating the results
let result = rxs.iter().fold(0, |accum, rx| accum + rx.recv() );
Looking at the source code in libcollections there doesn't seem to be such a method alltogether.
Metadata
Metadata
Assignees
Labels
No labels