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

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

http://github.com/jruderman/rust
Rust | 27 lines | 23 code | 4 blank | 0 comment | 2 complexity | 60bd42463a5d21a726afc37443edd86c MD5 | raw file
 1use std;
 2import task;
 3import pipes;
 4
 5fn start(c: pipes::chan<pipes::chan<~str>>) {
 6    let (ch, p) = pipes::stream();
 7    c.send(ch);
 8
 9    let mut a;
10    let mut b;
11    a = p.recv();
12    assert a == ~"A";
13    log(error, a);
14    b = p.recv();
15    assert b == ~"B";
16    log(error, b);
17}
18
19fn main() {
20    let (ch, p) = pipes::stream();
21    let child = task::spawn(|| start(ch) );
22
23    let c = p.recv();
24    c.send(~"A");
25    c.send(~"B");
26    task::yield();
27}