1 // Copyright 2012-2014 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.
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.
13 // no-pretty-expanded FIXME #15189
16 use std
::sync
::mpsc
::{channel, Sender}
;
18 pub fn main() { println!("===== WITHOUT THREADS ====="); test00(); }
20 fn test00_start(ch
: &Sender
<isize>, message
: isize, count
: isize) {
21 println
!("Starting test00_start");
24 println
!("Sending Message");
25 ch
.send(message
+ 0).unwrap();
28 println
!("Ending test00_start");
32 let number_of_tasks
: isize = 16;
33 let number_of_messages
: isize = 4;
35 println
!("Creating tasks");
37 let (tx
, rx
) = channel();
41 // Create and spawn tasks...
42 let mut results
= Vec
::new();
43 while i
< number_of_tasks
{
45 results
.push(thread
::spawn({
48 test00_start(&tx
, i
, number_of_messages
)
54 // Read from spawned tasks...
58 while i
< number_of_messages
{
59 let value
= rx
.recv().unwrap();
65 // Join spawned tasks...
66 for r
in results { r.join(); }
68 println
!("Completed: Final number is: ");
70 // assert (sum == (((number_of_tasks * (number_of_tasks - 1)) / 2) *
71 // number_of_messages));