]>
Commit | Line | Data |
---|---|---|
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 | ||
c34b1796 | 11 | |
1a4d82fc JJ |
12 | #![allow(dead_assignment)] |
13 | ||
14 | use std::sync::mpsc::channel; | |
223e47cc LB |
15 | |
16 | pub fn main() { test00(); } | |
17 | ||
18 | fn test00() { | |
c34b1796 AL |
19 | let mut r: isize = 0; |
20 | let mut sum: isize = 0; | |
1a4d82fc JJ |
21 | let (tx, rx) = channel(); |
22 | let mut tx0 = tx.clone(); | |
23 | let mut tx1 = tx.clone(); | |
24 | let mut tx2 = tx.clone(); | |
25 | let mut tx3 = tx.clone(); | |
c34b1796 AL |
26 | let number_of_messages: isize = 1000; |
27 | let mut i: isize = 0; | |
223e47cc | 28 | while i < number_of_messages { |
1a4d82fc JJ |
29 | tx0.send(i + 0).unwrap(); |
30 | tx1.send(i + 0).unwrap(); | |
31 | tx2.send(i + 0).unwrap(); | |
32 | tx3.send(i + 0).unwrap(); | |
223e47cc LB |
33 | i += 1; |
34 | } | |
35 | i = 0; | |
36 | while i < number_of_messages { | |
1a4d82fc | 37 | r = rx.recv().unwrap(); |
223e47cc | 38 | sum += r; |
1a4d82fc | 39 | r = rx.recv().unwrap(); |
223e47cc | 40 | sum += r; |
1a4d82fc | 41 | r = rx.recv().unwrap(); |
223e47cc | 42 | sum += r; |
1a4d82fc | 43 | r = rx.recv().unwrap(); |
223e47cc LB |
44 | sum += r; |
45 | i += 1; | |
46 | } | |
970d7e83 | 47 | assert_eq!(sum, 1998000); |
223e47cc LB |
48 | // assert (sum == 4 * ((number_of_messages * |
49 | // (number_of_messages - 1)) / 2)); | |
50 | ||
51 | } |