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 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();

View File

@ -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