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

25 lines
517 B
Rust
Raw Normal View History

extern mod std;
// We're trying to trigger a race between send and port destruction that
// results in the string not being freed
2012-08-15 14:10:46 -07:00
fn starship(&&ch: comm::Chan<~str>) {
2012-06-30 16:19:07 -07:00
for int::range(0, 10) |_i| {
comm::send(ch, ~"pew pew");
}
}
2012-01-04 21:14:53 -08:00
fn starbase() {
2012-06-30 16:19:07 -07:00
for int::range(0, 10) |_i| {
2012-08-27 14:22:25 -07:00
let p = comm::Port();
let c = comm::Chan(p);
2012-06-30 16:19:07 -07:00
task::spawn(|| starship(c) );
task::yield();
}
}
fn main() {
2012-06-30 16:19:07 -07:00
for int::range(0, 10) |_i| {
task::spawn(|| starbase() );
}
}