libextra: Remove various cells involved in Arcs.

I could have done this by making `Arc` use RAII, but this is too
involved for now.
This commit is contained in:
Patrick Walton 2013-12-05 14:56:41 -08:00
parent 9a6ebbbecc
commit 8c2ebe1622
2 changed files with 6 additions and 8 deletions

View File

@ -597,7 +597,6 @@ mod tests {
use arc::*; use arc::*;
use std::cell::Cell;
use std::comm; use std::comm;
use std::task; use std::task;
@ -628,7 +627,6 @@ mod tests {
let arc = ~MutexArc::new(false); let arc = ~MutexArc::new(false);
let arc2 = ~arc.clone(); let arc2 = ~arc.clone();
let (p,c) = comm::oneshot(); let (p,c) = comm::oneshot();
let c = Cell::new(c);
do task::spawn { do task::spawn {
// wait until parent gets in // wait until parent gets in
p.recv(); p.recv();
@ -638,8 +636,9 @@ mod tests {
}) })
} }
let mut c = Some(c);
arc.access_cond(|state, cond| { arc.access_cond(|state, cond| {
c.take().send(()); c.take_unwrap().send(());
assert!(!*state); assert!(!*state);
while !*state { while !*state {
cond.wait(); cond.wait();

View File

@ -676,7 +676,6 @@ mod tests {
use sync::*; use sync::*;
use std::cast; use std::cast;
use std::cell::Cell;
use std::comm; use std::comm;
use std::result; use std::result;
use std::task; use std::task;
@ -762,9 +761,9 @@ mod tests {
let s = Semaphore::new(1); let s = Semaphore::new(1);
let s2 = s.clone(); let s2 = s.clone();
let (p, c) = comm::stream(); let (p, c) = comm::stream();
let child_data = Cell::new((s2, c)); let mut child_data = Some((s2, c));
s.access(|| { s.access(|| {
let (s2, c) = child_data.take(); let (s2, c) = child_data.take_unwrap();
do task::spawn { do task::spawn {
c.send(()); c.send(());
s2.access(|| { }); s2.access(|| { });
@ -947,13 +946,13 @@ mod tests {
let mut sibling_convos = ~[]; let mut sibling_convos = ~[];
2.times(|| { 2.times(|| {
let (p, c) = comm::stream(); let (p, c) = comm::stream();
let c = Cell::new(c);
sibling_convos.push(p); sibling_convos.push(p);
let mi = m2.clone(); let mi = m2.clone();
// spawn sibling task // spawn sibling task
do task::spawn { // linked do task::spawn { // linked
let mut c = Some(c);
mi.lock_cond(|cond| { mi.lock_cond(|cond| {
let c = c.take(); let c = c.take_unwrap();
c.send(()); // tell sibling to go ahead c.send(()); // tell sibling to go ahead
(|| { (|| {
cond.wait(); // block forever cond.wait(); // block forever