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

27 lines
513 B
Rust
Raw Normal View History

// xfail-stage0
2010-06-23 23:03:09 -05:00
// This checks that preemption works.
impure 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;
}
}
impure 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";
}