diff options
| author | bors <bors@rust-lang.org> | 2015-01-12 00:21:25 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-01-12 00:21:25 +0000 |
| commit | 67736510aed0090f7bed69dbe6218a3d6b45e491 (patch) | |
| tree | c0cf5f305b8f1e6634b6c60d46d3206c99fa1d61 | |
| parent | 10305fcfdcf01cebaafa57b599506e36cc09055f (diff) | |
| parent | 8af47508e9dcc9537468989ccf7f656024ead176 (diff) | |
Merge pull request #20899 from TeXitoi/fix-shootout-threadring
fix shootout-threadring.rs Reviewed-by: alexcrichton
| -rw-r--r-- | src/test/bench/shootout-threadring.rs | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/test/bench/shootout-threadring.rs b/src/test/bench/shootout-threadring.rs index ea4b3c46312..47f17997e84 100644 --- a/src/test/bench/shootout-threadring.rs +++ b/src/test/bench/shootout-threadring.rs @@ -41,18 +41,19 @@ use std::sync::mpsc::{channel, Sender, Receiver}; use std::thread::Thread; -fn start(n_tasks: int, token: int) { +fn start(n_tasks: i32, token: i32) { let (tx, mut rx) = channel(); tx.send(token).unwrap(); - for i in range(2, n_tasks + 1) { + let mut guards = Vec::with_capacity(n_tasks as usize); + for i in 2 .. n_tasks + 1 { let (tx, next_rx) = channel(); - Thread::spawn(move|| roundtrip(i, tx, rx)); - rx = next_rx; + let cur_rx = std::mem::replace(&mut rx, next_rx); + guards.push(Thread::scoped(move|| roundtrip(i, tx, cur_rx))); } - Thread::spawn(move|| roundtrip(1, tx, rx)); + let guard = Thread::scoped(move|| roundtrip(1, tx, rx)); } -fn roundtrip(id: int, tx: Sender<int>, rx: Receiver<int>) { +fn roundtrip(id: i32, tx: Sender<i32>, rx: Receiver<i32>) { for token in rx.iter() { if token == 1 { println!("{}", id); @@ -64,7 +65,6 @@ fn roundtrip(id: int, tx: Sender<int>, rx: Receiver<int>) { fn main() { let args = std::os::args(); - let args = args.as_slice(); let token = if std::os::getenv("RUST_BENCH").is_some() { 2000000 } else { |
