Skip to content

Commit 5cdea7a

Browse files
committed
libstd: Remove many uses of Cell
1 parent 736155e commit 5cdea7a

26 files changed

+126
-270
lines changed

src/libextra/arc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -628,10 +628,10 @@ mod tests {
628628
let arc = ~MutexArc::new(false);
629629
let arc2 = ~arc.clone();
630630
let (p,c) = comm::oneshot();
631-
let (c,p) = (Cell::new(c), Cell::new(p));
631+
let c = Cell::new(c);
632632
do task::spawn || {
633633
// wait until parent gets in
634-
p.take().recv();
634+
p.recv();
635635
arc2.access_cond(|state, cond| {
636636
*state = true;
637637
cond.signal();

src/libextra/future.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
#[allow(missing_doc)];
2727

28-
use std::cell::Cell;
2928
use std::comm::{PortOne, oneshot};
3029
use std::task;
3130
use std::util::replace;
@@ -114,9 +113,8 @@ impl<A:Send> Future<A> {
114113
* waiting for the result to be received on the port.
115114
*/
116115

117-
let port = Cell::new(port);
118116
do Future::from_fn {
119-
port.take().recv()
117+
port.recv()
120118
}
121119
}
122120

@@ -159,7 +157,6 @@ impl<A:Send> Future<A> {
159157
mod test {
160158
use future::Future;
161159

162-
use std::cell::Cell;
163160
use std::comm::oneshot;
164161
use std::task;
165162

@@ -223,9 +220,9 @@ mod test {
223220
#[test]
224221
fn test_sendable_future() {
225222
let expected = "schlorf";
226-
let f = Cell::new(do Future::spawn { expected });
223+
let f = do Future::spawn { expected };
227224
do task::spawn {
228-
let mut f = f.take();
225+
let mut f = f;
229226
let actual = f.get();
230227
assert_eq!(actual, expected);
231228
}

src/libextra/test.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,6 @@ pub fn run_test(force_ignore: bool,
864864
fn run_test_inner(desc: TestDesc,
865865
monitor_ch: SharedChan<MonitorMsg>,
866866
testfn: proc()) {
867-
let testfn_cell = ::std::cell::Cell::new(testfn);
868867
do task::spawn {
869868
let mut task = task::task();
870869
task.unlinked();
@@ -873,7 +872,7 @@ pub fn run_test(force_ignore: bool,
873872
StaticTestName(name) => SendStrStatic(name),
874873
});
875874
let result_future = task.future_result();
876-
task.spawn(testfn_cell.take());
875+
task.spawn(testfn);
877876

878877
let task_result = result_future.recv();
879878
let test_result = calc_result(&desc, task_result.is_ok());

src/libextra/workcache.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use json::ToJson;
1515
use serialize::{Encoder, Encodable, Decoder, Decodable};
1616
use arc::{Arc,RWArc};
1717
use treemap::TreeMap;
18-
use std::cell::Cell;
1918
use std::comm::{PortOne, oneshot};
2019
use std::{str, task};
2120
use std::io;
@@ -430,15 +429,13 @@ impl<'self> Prep<'self> {
430429
debug!("Cache miss!");
431430
let (port, chan) = oneshot();
432431
let blk = bo.take_unwrap();
433-
let chan = Cell::new(chan);
434432

435433
// XXX: What happens if the task fails?
436434
do task::spawn {
437435
let mut exe = Exec {
438436
discovered_inputs: WorkMap::new(),
439437
discovered_outputs: WorkMap::new(),
440438
};
441-
let chan = chan.take();
442439
let v = blk(&mut exe);
443440
chan.send((exe, v));
444441
}

0 commit comments

Comments
 (0)