Loading RustViz Engine...
Stream computations from multiple workers into a single aggregator thread.
This problem is currently in blueprint template mode. Once the concept foundation is finalized, live in-browser WebAssembly compilation and test assertion runners will be enabled here.
use std::sync::mpsc;
use std::thread;
pub fn aggregate_work(work_items: Vec<i32>) -> i32 {
let (tx, rx) = mpsc::channel();
for item in work_items {
let sender = tx.clone();
thread::spawn(move || {
sender.send(item * 2).unwrap();
});
}
drop(tx);
rx.into_iter().sum()
}