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