summary refs log tree commit diff
path: root/src/test/run-pass/task-comm-chan-cleanup4.rs
blob: 4593c90293a21e7839bb2e10ef720e4ab64fe8f5 (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
use std;
import int;
import comm;
import task;

// We're trying to trigger a race between send and port destruction that
// results in the string not being freed

fn starship(&&ch: comm::chan<str>) {
    int::range(0, 10) { |_i|
        comm::send(ch, "pew pew");
    }
}

fn starbase() {
    int::range(0, 10) { |_i|
        let p = comm::port();
        let c = comm::chan(p);
        task::spawn {|| starship(c);};
        task::yield();
    }
}

fn main() {
    int::range(0, 10) { |_i|
        task::spawn {|| starbase();};
    }
}