Skip to content

Commit 4a9d4aa

Browse files
committed
bench: Fix botched option dances. rs=demuting
1 parent 9b08cd4 commit 4a9d4aa

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

src/test/bench/msgsend-ring-mutex-arcs.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ extern mod std;
1919
use std::time;
2020
use std::arc;
2121
use std::future;
22+
use core::cell::Cell;
2223

2324
// A poor man's pipe.
2425
type pipe = arc::MutexARC<~[uint]>;
@@ -77,7 +78,7 @@ fn main() {
7778
let msg_per_task = uint::from_str(args[2]).get();
7879

7980
let (num_chan, num_port) = init();
80-
let mut num_chan = Some(num_chan);
81+
let mut num_chan = Cell(num_chan);
8182

8283
let start = time::precise_time_s();
8384

@@ -87,19 +88,19 @@ fn main() {
8788
for uint::range(1u, num_tasks) |i| {
8889
//error!("spawning %?", i);
8990
let (new_chan, num_port) = init();
90-
let num_chan2 = Cell(num_chan);
91+
let num_chan2 = Cell(num_chan.take());
9192
let num_port = Cell(num_port);
9293
let new_future = do future::spawn() {
9394
let num_chan = num_chan2.take();
9495
let num_port1 = num_port.take();
9596
thread_ring(i, msg_per_task, num_chan, num_port1)
9697
};
9798
futures.push(new_future);
98-
num_chan = Some(new_chan);
99+
num_chan.put_back(new_chan);
99100
};
100101

101102
// do our iteration
102-
thread_ring(0, msg_per_task, option::unwrap(num_chan), num_port);
103+
thread_ring(0, msg_per_task, num_chan.take(), num_port);
103104

104105
// synchronize
105106
for futures.each |f| { f.get() };

src/test/bench/msgsend-ring-pipes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ fn main() {
7171
let msg_per_task = uint::from_str(args[2]).get();
7272

7373
let (num_chan, num_port) = ring::init();
74-
let mut num_chan = Some(num_chan);
74+
let mut num_chan = Cell(num_chan);
7575

7676
let start = time::precise_time_s();
7777

@@ -81,19 +81,19 @@ fn main() {
8181
for uint::range(1u, num_tasks) |i| {
8282
//error!("spawning %?", i);
8383
let (new_chan, num_port) = ring::init();
84-
let num_chan2 = Cell(num_chan);
84+
let num_chan2 = Cell(num_chan.take());
8585
let num_port = Cell(num_port);
8686
let new_future = do future::spawn || {
8787
let num_chan = num_chan2.take();
8888
let num_port1 = num_port.take();
8989
thread_ring(i, msg_per_task, num_chan, num_port1)
9090
};
9191
futures.push(new_future);
92-
num_chan = Some(new_chan);
92+
num_chan.put_back(new_chan);
9393
};
9494

9595
// do our iteration
96-
thread_ring(0, msg_per_task, option::unwrap(num_chan), num_port);
96+
thread_ring(0, msg_per_task, num_chan.take(), num_port);
9797

9898
// synchronize
9999
for futures.each |f| { f.get() };

src/test/bench/msgsend-ring-rw-arcs.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
// This also serves as a pipes test, because ARCs are implemented with pipes.
1717

1818
extern mod std;
19+
20+
use core::cell::Cell;
1921
use std::time;
2022
use std::arc;
2123
use std::future;
@@ -77,7 +79,7 @@ fn main() {
7779
let msg_per_task = uint::from_str(args[2]).get();
7880

7981
let (num_chan, num_port) = init();
80-
let mut num_chan = Some(num_chan);
82+
let mut num_chan = Cell(num_chan);
8183

8284
let start = time::precise_time_s();
8385

@@ -87,19 +89,19 @@ fn main() {
8789
for uint::range(1u, num_tasks) |i| {
8890
//error!("spawning %?", i);
8991
let (new_chan, num_port) = init();
90-
let num_chan2 = Cell(num_chan);
92+
let num_chan2 = Cell(num_chan.take());
9193
let num_port = Cell(num_port);
9294
let new_future = do future::spawn {
9395
let num_chan = num_chan2.take();
9496
let num_port1 = num_port.take();
9597
thread_ring(i, msg_per_task, num_chan, num_port1)
9698
};
9799
futures.push(new_future);
98-
num_chan = Some(new_chan);
100+
num_chan.put_back(new_chan);
99101
};
100102

101103
// do our iteration
102-
thread_ring(0, msg_per_task, option::unwrap(num_chan), num_port);
104+
thread_ring(0, msg_per_task, num_chan.take(), num_port);
103105

104106
// synchronize
105107
for futures.each |f| { f.get() };

src/test/bench/shootout-chameneos-redux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ extern mod std;
1414
use std::oldmap;
1515
use std::oldmap::HashMap;
1616
use std::sort;
17-
use std::cell::Cell;
17+
use core::cell::Cell;
1818
use core::comm::*;
1919

2020
fn print_complements() {

0 commit comments

Comments
 (0)