2011-09-09 13:34:22 -07:00
|
|
|
// xfail-win32
|
2011-08-06 10:07:39 -07:00
|
|
|
use std;
|
2011-12-13 16:25:51 -08:00
|
|
|
import comm;
|
|
|
|
import task;
|
2011-08-06 10:07:39 -07:00
|
|
|
|
2012-01-04 21:14:53 -08:00
|
|
|
fn start(c: comm::chan<int>, i0: int) {
|
|
|
|
let i = i0;
|
|
|
|
while i > 0 {
|
|
|
|
comm::send(c, 0);
|
|
|
|
i = i - 1;
|
|
|
|
}
|
2010-08-24 21:06:56 -07:00
|
|
|
}
|
|
|
|
|
2011-04-19 13:35:49 -07:00
|
|
|
fn main() {
|
2011-08-25 11:20:43 -07:00
|
|
|
let p = comm::port();
|
2010-09-07 18:01:35 -07:00
|
|
|
// Spawn a task that sends us back messages. The parent task
|
|
|
|
// is likely to terminate before the child completes, so from
|
|
|
|
// the child's point of view the receiver may die. We should
|
|
|
|
// drop messages on the floor in this case, and not crash!
|
2012-01-04 21:14:53 -08:00
|
|
|
let ch = comm::chan(p);
|
|
|
|
let child = task::spawn {|| start(ch, 10); };
|
2011-08-25 11:20:43 -07:00
|
|
|
let c = comm::recv(p);
|
2011-08-10 09:27:22 -07:00
|
|
|
}
|