summary refs log tree commit diff
path: root/src/test/run-pass/lazychan.rs
blob: 8651c81a41fc7c30dbd4540e2f7886536cf21a42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// -*- rust -*-

use std;
import task;
import comm::*;

fn main() {
    let p = port();
    let ch = chan(p);
    let mut y: int;

    task::spawn {|| child(ch); };
    y = recv(p);
    #debug("received 1");
    log(debug, y);
    assert (y == 10);

    task::spawn {|| child(ch); };
    y = recv(p);
    #debug("received 2");
    log(debug, y);
    assert (y == 10);
}

fn child(c: chan<int>) { send(c, 10); }