321fd80219
Add a loop {} construct for infinite loops, and use it in test cases. See #1906 for details.
23 lines
533 B
Rust
23 lines
533 B
Rust
// xfail-test
|
|
// This checks that preemption works.
|
|
|
|
fn starve_main(alive: chan<int>) {
|
|
#debug("signalling main");
|
|
alive <| 1;
|
|
#debug("starving main");
|
|
let i: int = 0;
|
|
loop { i += 1; }
|
|
}
|
|
|
|
fn main() {
|
|
let alive: port<int> = port();
|
|
#debug("main started");
|
|
let s: task = spawn starve_main(chan(alive));
|
|
let i: int;
|
|
#debug("main waiting for alive signal");
|
|
alive |> i;
|
|
#debug("main got alive signal");
|
|
while i < 50 { #debug("main iterated"); i += 1; }
|
|
#debug("main completed");
|
|
}
|