librustdoc: Don't use finally
, shaving off a Cell
.
This commit is contained in:
parent
fdd6750570
commit
ebe8ac88a7
1 changed files with 25 additions and 13 deletions
|
@ -46,7 +46,6 @@ use std::io::File;
|
||||||
use std::os;
|
use std::os;
|
||||||
use std::str;
|
use std::str;
|
||||||
use std::task;
|
use std::task;
|
||||||
use std::unstable::finally::Finally;
|
|
||||||
use std::vec;
|
use std::vec;
|
||||||
|
|
||||||
use extra::arc::RWArc;
|
use extra::arc::RWArc;
|
||||||
|
@ -642,6 +641,22 @@ impl<'self> Cache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Progress {
|
||||||
|
JobNew,
|
||||||
|
JobDone,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A helper object to unconditionally send a value on a chanel.
|
||||||
|
struct ChannelGuard {
|
||||||
|
channel: SharedChan<Progress>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for ChannelGuard {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
self.channel.send(JobDone)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Context {
|
impl Context {
|
||||||
/// Recurse in the directory structure and change the "root path" to make
|
/// Recurse in the directory structure and change the "root path" to make
|
||||||
/// sure it always points to the top (relatively)
|
/// sure it always points to the top (relatively)
|
||||||
|
@ -674,8 +689,6 @@ impl Context {
|
||||||
Die,
|
Die,
|
||||||
Process(Context, clean::Item),
|
Process(Context, clean::Item),
|
||||||
}
|
}
|
||||||
enum Progress { JobNew, JobDone }
|
|
||||||
|
|
||||||
let workers = match os::getenv("RUSTDOC_WORKERS") {
|
let workers = match os::getenv("RUSTDOC_WORKERS") {
|
||||||
Some(s) => {
|
Some(s) => {
|
||||||
match from_str::<uint>(s) {
|
match from_str::<uint>(s) {
|
||||||
|
@ -725,17 +738,16 @@ impl Context {
|
||||||
match port.recv() {
|
match port.recv() {
|
||||||
Process(cx, item) => {
|
Process(cx, item) => {
|
||||||
let mut cx = cx;
|
let mut cx = cx;
|
||||||
let item = Cell::new(item);
|
|
||||||
(|| {
|
// If we fail, everything else should still get
|
||||||
cx.item(item.take(), |cx, item| {
|
// completed.
|
||||||
|
let _guard = ChannelGuard {
|
||||||
|
channel: prog_chan.clone(),
|
||||||
|
};
|
||||||
|
cx.item(item, |cx, item| {
|
||||||
prog_chan.send(JobNew);
|
prog_chan.send(JobNew);
|
||||||
chan.send(Process(cx.clone(), item));
|
chan.send(Process(cx.clone(), item));
|
||||||
})
|
})
|
||||||
}).finally(|| {
|
|
||||||
// If we fail, everything else should still get
|
|
||||||
// completed
|
|
||||||
prog_chan.send(JobDone);
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
Die => break,
|
Die => break,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue