From 8c2ebe1622681c2a93a2fcf2673a5671fd110ead Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Thu, 5 Dec 2013 14:56:41 -0800 Subject: [PATCH] libextra: Remove various cells involved in `Arc`s. I could have done this by making `Arc` use RAII, but this is too involved for now. --- src/libextra/arc.rs | 5 ++--- src/libextra/sync.rs | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/libextra/arc.rs b/src/libextra/arc.rs index 58007e491da..005328c6934 100644 --- a/src/libextra/arc.rs +++ b/src/libextra/arc.rs @@ -597,7 +597,6 @@ mod tests { use arc::*; - use std::cell::Cell; use std::comm; use std::task; @@ -628,7 +627,6 @@ mod tests { let arc = ~MutexArc::new(false); let arc2 = ~arc.clone(); let (p,c) = comm::oneshot(); - let c = Cell::new(c); do task::spawn { // wait until parent gets in p.recv(); @@ -638,8 +636,9 @@ mod tests { }) } + let mut c = Some(c); arc.access_cond(|state, cond| { - c.take().send(()); + c.take_unwrap().send(()); assert!(!*state); while !*state { cond.wait(); diff --git a/src/libextra/sync.rs b/src/libextra/sync.rs index 6167a429380..88207bfbae4 100644 --- a/src/libextra/sync.rs +++ b/src/libextra/sync.rs @@ -676,7 +676,6 @@ mod tests { use sync::*; use std::cast; - use std::cell::Cell; use std::comm; use std::result; use std::task; @@ -762,9 +761,9 @@ mod tests { let s = Semaphore::new(1); let s2 = s.clone(); let (p, c) = comm::stream(); - let child_data = Cell::new((s2, c)); + let mut child_data = Some((s2, c)); s.access(|| { - let (s2, c) = child_data.take(); + let (s2, c) = child_data.take_unwrap(); do task::spawn { c.send(()); s2.access(|| { }); @@ -947,13 +946,13 @@ mod tests { let mut sibling_convos = ~[]; 2.times(|| { let (p, c) = comm::stream(); - let c = Cell::new(c); sibling_convos.push(p); let mi = m2.clone(); // spawn sibling task do task::spawn { // linked + let mut c = Some(c); mi.lock_cond(|cond| { - let c = c.take(); + let c = c.take_unwrap(); c.send(()); // tell sibling to go ahead (|| { cond.wait(); // block forever