]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/task-comm-6.rs
Imported Upstream version 0.7
[rustc.git] / src / test / run-pass / task-comm-6.rs
CommitLineData
223e47cc
LB
1// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
970d7e83
LB
11use std::comm::Chan;
12use std::comm;
223e47cc
LB
13
14pub fn main() { test00(); }
15
16fn test00() {
17 let mut r: int = 0;
18 let mut sum: int = 0;
970d7e83 19 let p = comm::PortSet::new();
223e47cc
LB
20 let c0 = p.chan();
21 let c1 = p.chan();
22 let c2 = p.chan();
23 let c3 = p.chan();
24 let number_of_messages: int = 1000;
25 let mut i: int = 0;
26 while i < number_of_messages {
27 c0.send(i + 0);
28 c1.send(i + 0);
29 c2.send(i + 0);
30 c3.send(i + 0);
31 i += 1;
32 }
33 i = 0;
34 while i < number_of_messages {
35 r = p.recv();
36 sum += r;
37 r = p.recv();
38 sum += r;
39 r = p.recv();
40 sum += r;
41 r = p.recv();
42 sum += r;
43 i += 1;
44 }
970d7e83 45 assert_eq!(sum, 1998000);
223e47cc
LB
46 // assert (sum == 4 * ((number_of_messages *
47 // (number_of_messages - 1)) / 2));
48
49}