PageRenderTime 13ms CodeModel.GetById 1ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

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

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