rust/src/test/run-pass/preempt.rs

29 lines
531 B
Rust
Raw Normal View History

// xfail-stage0
// xfail-stage1
// xfail-stage2
2010-06-23 23:03:09 -05:00
// This checks that preemption works.
2011-04-19 15:35:49 -05:00
fn starve_main(chan[int] alive) {
2010-06-23 23:03:09 -05:00
log "signalling main";
alive <| 1;
log "starving main";
let int i = 0;
while (true) {
i += 1;
}
}
2011-04-19 15:35:49 -05:00
fn main() {
2010-06-23 23:03:09 -05:00
let port[int] alive = port();
log "main started";
let task s = spawn starve_main(chan(alive));
let int i;
log "main waiting for alive signal";
i <- alive;
log "main got alive signal";
while (i < 50) {
2010-06-23 23:03:09 -05:00
log "main iterated";
i += 1;
}
log "main completed";
}