rust/src/test/run-pass/task-comm-chan-cleanup4.rs

28 lines
548 B
Rust
Raw Normal View History

use std;
import int;
import comm;
import task;
// We're trying to trigger a race between send and port destruction that
// results in the string not being freed
fn starship(&&ch: comm::chan<str>) {
for int::range(0, 10) { |_i|
comm::send(ch, "pew pew");
}
}
2012-01-04 23:14:53 -06:00
fn starbase() {
for int::range(0, 10) { |_i|
let p = comm::port();
2012-01-04 23:14:53 -06:00
let c = comm::chan(p);
task::spawn {|| starship(c);};
task::yield();
}
}
fn main() {
for int::range(0, 10) { |_i|
2012-01-04 23:14:53 -06:00
task::spawn {|| starbase();};
}
}