This repository has been archived on 2018-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
literate-tribble/embed/src/lib.rs

20 lines
346 B
Rust

use std::thread;
#[no_mangle]
pub extern fn process() {
let handles: Vec<_> = (0..10).map(|_| {
thread::spawn(|| {
let mut x = 0;
for _ in 0..5_000_000 {
x += 1
}
x // return
})
}).collect();
for h in handles {
println!("Thread finished with count={}",
h.join().map_err(|_| "Could not join a thread").unwrap());
}
}