rust/src/test/run-pass/task-comm-10.rs
unknown 44bef5f2cb Introduced task handles.
This is the new way to refer to tasks in rust-land. Currently all they
do is serve as a key to look up the old rust_task structure. Ideally
they won't be ref counted, but baby steps.
2011-08-08 16:55:38 -07:00

28 lines
500 B
Rust

use std;
import std::task;
import std::comm;
fn start(pcc: *u8) {
let c = comm::chan_from_unsafe_ptr(pcc);
let p = comm::mk_port[str]();
c.send(p.mk_chan().unsafe_ptr());
let a;
let b;
a = p.recv();
log_err a;
b = p.recv();
log_err b;
}
fn main() {
let p = comm::mk_port[*u8]();
let child = spawn start(p.mk_chan().unsafe_ptr());
let pc = p.recv();
let c = comm::chan_from_unsafe_ptr(pc);
c.send("A");
c.send("B");
task::yield();
}