rust/src/test/run-pass/task-comm-13.rs

17 lines
442 B
Rust
Raw Normal View History

use std;
import std::task;
import std::comm;
fn start(pc: *u8, start: int, number_of_messages: int) {
let c = comm::chan_from_unsafe_ptr(pc);
2011-07-27 07:19:39 -05:00
let i: int = 0;
while i < number_of_messages { c.send(start + i); i += 1; }
}
2011-07-27 07:19:39 -05:00
fn main() {
log "Check that we don't deadlock.";
let p : comm::_port[int] = comm::mk_port();
let a: task = spawn start(p.mk_chan().unsafe_ptr(), 0, 10);
task::join(a);
log "Joined task";
}