PageRenderTime 12ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 2ms app.codeStats 0ms

/src/test/run-pass/comm.rs

http://github.com/jruderman/rust
Rust | 24 lines | 20 code | 3 blank | 1 comment | 1 complexity | 8931667f3f9c55e17974008b7763b6b1 MD5 | raw file
 1// -*- rust -*-
 2
 3use std;
 4import comm;
 5import comm::chan;
 6import comm::send;
 7import comm::recv;
 8import task;
 9
10fn main() {
11    let p = comm::port();
12    let ch = comm::chan(p);
13    let t = task::spawn(|| child(ch) );
14    let y = recv(p);
15    error!{"received"};
16    log(error, y);
17    assert (y == 10);
18}
19
20fn child(c: chan<int>) {
21    error!{"sending"};
22    send(c, 10);
23    error!{"value sent"};
24}