rust/src/test/run-pass/send-iloop.rs

29 lines
544 B
Rust
Raw Normal View History

// xfail-win32
2011-09-16 12:49:41 -05:00
use std;
import task;
import comm;
import uint;
2011-09-16 12:49:41 -05:00
2012-01-04 23:14:53 -06:00
fn die() {
2011-09-16 12:49:41 -05:00
fail;
}
2012-01-04 23:14:53 -06:00
fn iloop() {
2012-06-30 18:19:07 -05:00
task::spawn(|| die() );
2011-09-16 12:49:41 -05:00
let p = comm::port::<()>();
let c = comm::chan(p);
loop {
// Sending and receiving here because these actions yield,
// at which point our child can kill us
2011-09-16 12:49:41 -05:00
comm::send(c, ());
comm::recv(p);
2011-09-16 12:49:41 -05:00
}
}
fn main() {
2012-06-30 18:19:07 -05:00
for uint::range(0u, 16u) |_i| {
let builder = task::builder();
2012-02-18 18:34:42 -06:00
task::unsupervise(builder);
2012-06-30 18:19:07 -05:00
task::run(builder, || iloop() );
}
2011-09-16 12:49:41 -05:00
}