diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2013-12-04 19:34:08 -0800 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2013-12-10 15:13:12 -0800 |
| commit | ebe8ac88a7492679846827f374effff46b070278 (patch) | |
| tree | 87557253454979f6cff5ba43f849bec7ffa9f052 | |
| parent | fdd6750570cf1434264a601fd2b749d7fe01dee8 (diff) | |
librustdoc: Don't use `finally`, shaving off a `Cell`.
| -rw-r--r-- | src/librustdoc/html/render.rs | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 0df4820d822..f988cad5004 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -46,7 +46,6 @@ use std::io::File; use std::os; use std::str; use std::task; -use std::unstable::finally::Finally; use std::vec; 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 { /// Recurse in the directory structure and change the "root path" to make /// sure it always points to the top (relatively) @@ -674,8 +689,6 @@ impl Context { Die, Process(Context, clean::Item), } - enum Progress { JobNew, JobDone } - let workers = match os::getenv("RUSTDOC_WORKERS") { Some(s) => { match from_str::<uint>(s) { @@ -725,16 +738,15 @@ impl Context { match port.recv() { Process(cx, item) => { let mut cx = cx; - let item = Cell::new(item); - (|| { - cx.item(item.take(), |cx, item| { - prog_chan.send(JobNew); - chan.send(Process(cx.clone(), item)); - }) - }).finally(|| { - // If we fail, everything else should still get - // completed - prog_chan.send(JobDone); + + // If we fail, everything else should still get + // completed. + let _guard = ChannelGuard { + channel: prog_chan.clone(), + }; + cx.item(item, |cx, item| { + prog_chan.send(JobNew); + chan.send(Process(cx.clone(), item)); }) } Die => break, |
