Skip to content

Commit ebe8ac8

Browse files
committed
librustdoc: Don't use finally, shaving off a Cell.
1 parent fdd6750 commit ebe8ac8

File tree

1 file changed

+25
-13
lines changed

1 file changed

+25
-13
lines changed

src/librustdoc/html/render.rs

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ use std::io::File;
4646
use std::os;
4747
use std::str;
4848
use std::task;
49-
use std::unstable::finally::Finally;
5049
use std::vec;
5150

5251
use extra::arc::RWArc;
@@ -642,6 +641,22 @@ impl<'self> Cache {
642641
}
643642
}
644643

644+
enum Progress {
645+
JobNew,
646+
JobDone,
647+
}
648+
649+
/// A helper object to unconditionally send a value on a chanel.
650+
struct ChannelGuard {
651+
channel: SharedChan<Progress>,
652+
}
653+
654+
impl Drop for ChannelGuard {
655+
fn drop(&mut self) {
656+
self.channel.send(JobDone)
657+
}
658+
}
659+
645660
impl Context {
646661
/// Recurse in the directory structure and change the "root path" to make
647662
/// sure it always points to the top (relatively)
@@ -674,8 +689,6 @@ impl Context {
674689
Die,
675690
Process(Context, clean::Item),
676691
}
677-
enum Progress { JobNew, JobDone }
678-
679692
let workers = match os::getenv("RUSTDOC_WORKERS") {
680693
Some(s) => {
681694
match from_str::<uint>(s) {
@@ -725,16 +738,15 @@ impl Context {
725738
match port.recv() {
726739
Process(cx, item) => {
727740
let mut cx = cx;
728-
let item = Cell::new(item);
729-
(|| {
730-
cx.item(item.take(), |cx, item| {
731-
prog_chan.send(JobNew);
732-
chan.send(Process(cx.clone(), item));
733-
})
734-
}).finally(|| {
735-
// If we fail, everything else should still get
736-
// completed
737-
prog_chan.send(JobDone);
741+
742+
// If we fail, everything else should still get
743+
// completed.
744+
let _guard = ChannelGuard {
745+
channel: prog_chan.clone(),
746+
};
747+
cx.item(item, |cx, item| {
748+
prog_chan.send(JobNew);
749+
chan.send(Process(cx.clone(), item));
738750
})
739751
}
740752
Die => break,

0 commit comments

Comments
 (0)