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