@@ -307,11 +307,17 @@ pub fn run(mut krate: clean::Crate, dst: Path) -> io::IoResult<()> {
307
307
}
308
308
309
309
let index = try!( build_index ( & krate, & mut cache) ) ;
310
- try!( write_shared ( & cx, & krate, & cache, index) ) ;
310
+
311
+ // Freeze the cache now that the index has been built. Put an Arc into TLS
312
+ // for future parallelization opportunities
313
+ let cache = Arc :: new ( cache) ;
314
+ cache_key. replace ( Some ( cache. clone ( ) ) ) ;
315
+
316
+ try!( write_shared ( & cx, & krate, & * cache, index) ) ;
311
317
let krate = try!( render_sources ( & mut cx, krate) ) ;
312
318
313
319
// And finally render the whole crate's documentation
314
- cx. krate ( krate, cache )
320
+ cx. krate ( krate)
315
321
}
316
322
317
323
fn build_index ( krate : & clean:: Crate , cache : & mut Cache ) -> io:: IoResult < String > {
@@ -954,16 +960,13 @@ impl Context {
954
960
///
955
961
/// This currently isn't parallelized, but it'd be pretty easy to add
956
962
/// parallelization to this function.
957
- fn krate ( self , mut krate : clean:: Crate , cache : Cache ) -> io:: IoResult < ( ) > {
963
+ fn krate ( self , mut krate : clean:: Crate ) -> io:: IoResult < ( ) > {
958
964
let mut item = match krate. module . take ( ) {
959
965
Some ( i) => i,
960
966
None => return Ok ( ( ) )
961
967
} ;
962
968
item. name = Some ( krate. name ) ;
963
969
964
- // using a rwarc makes this parallelizable in the future
965
- cache_key. replace ( Some ( Arc :: new ( cache) ) ) ;
966
-
967
970
let mut work = vec ! ( ( self , item) ) ;
968
971
loop {
969
972
match work. pop ( ) {
0 commit comments