Merge pull request #20515 from tshepang/modernise-ping-pong-benchmark

bench: remove warnings from rt-messaging-ping-pong.rs

Reviewed-by: alexcrichton
This commit is contained in:
bors 2015-01-04 21:36:41 +00:00
commit 589c38a3af

View file

@ -20,7 +20,6 @@
use std::sync::mpsc::channel;
use std::os;
use std::thread::Thread;
use std::uint;
// This is a simple bench that creates M pairs of tasks. These
// tasks ping-pong back and forth over a pair of streams. This is a
@ -31,24 +30,24 @@ fn ping_pong_bench(n: uint, m: uint) {
// Create pairs of tasks that pingpong back and forth.
fn run_pair(n: uint) {
// Create a stream A->B
let (atx, arx) = channel::<()>();
// Create a stream B->A
let (btx, brx) = channel::<()>();
// Create a channel: A->B
let (atx, arx) = channel();
// Create a channel: B->A
let (btx, brx) = channel();
Thread::spawn(move|| {
let (tx, rx) = (atx, brx);
for _ in range(0, n) {
tx.send(());
rx.recv();
tx.send(()).unwrap();
rx.recv().unwrap();
}
}).detach();
Thread::spawn(move|| {
let (tx, rx) = (btx, arx);
for _ in range(0, n) {
rx.recv();
tx.send(());
rx.recv().unwrap();
tx.send(()).unwrap();
}
}).detach();
}