summary refs log tree commit diff
path: root/src/test/run-pass/basic.rs
blob: 6f8fa6e3e70ff7f64e443f3404397c52260d1d4c (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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// -*- rust -*-

extern mod std;
use comm::send;
use comm::Chan;
use comm::recv;

fn a(c: Chan<int>) {
    if true {
        debug!("task a");
        debug!("task a");
        debug!("task a");
        debug!("task a");
        debug!("task a");
    }
    send(c, 10);
}

fn k(x: int) -> int { return 15; }

fn g(x: int, y: ~str) -> int {
    log(debug, x);
    log(debug, y);
    let z: int = k(1);
    return z;
}

fn main() {
    let mut n: int = 2 + 3 * 7;
    let s: ~str = ~"hello there";
    let p = comm::Port();
    let ch = comm::Chan(&p);
    task::spawn(|| a(ch) );
    task::spawn(|| b(ch) );
    let mut x: int = 10;
    x = g(n, s);
    log(debug, x);
    n = recv(p);
    n = recv(p);
    debug!("children finished, root finishing");
}

fn b(c: Chan<int>) {
    if true {
        debug!("task b");
        debug!("task b");
        debug!("task b");
        debug!("task b");
        debug!("task b");
        debug!("task b");
    }
    send(c, 10);
}