@@ -46,7 +46,6 @@ use std::io::File;
46
46
use std:: os;
47
47
use std:: str;
48
48
use std:: task;
49
- use std:: unstable:: finally:: Finally ;
50
49
use std:: vec;
51
50
52
51
use extra:: arc:: RWArc ;
@@ -642,6 +641,22 @@ impl<'self> Cache {
642
641
}
643
642
}
644
643
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
+
645
660
impl Context {
646
661
/// Recurse in the directory structure and change the "root path" to make
647
662
/// sure it always points to the top (relatively)
@@ -674,8 +689,6 @@ impl Context {
674
689
Die ,
675
690
Process ( Context , clean:: Item ) ,
676
691
}
677
- enum Progress { JobNew , JobDone }
678
-
679
692
let workers = match os:: getenv ( "RUSTDOC_WORKERS" ) {
680
693
Some ( s) => {
681
694
match from_str :: < uint > ( s) {
@@ -725,16 +738,15 @@ impl Context {
725
738
match port. recv ( ) {
726
739
Process ( cx, item) => {
727
740
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) ) ;
738
750
} )
739
751
}
740
752
Die => break ,
0 commit comments