44//! various caches, it's not really advanced at the moment.
55mod topologic_sort;
66
7+ use std:: time:: Duration ;
8+
79use hir:: db:: DefDatabase ;
810use ide_db:: {
911 base_db:: {
@@ -14,7 +16,7 @@ use ide_db::{
1416} ;
1517use rustc_hash:: FxHashSet ;
1618
17- use crate :: { prime_caches , RootDatabase } ;
19+ use crate :: RootDatabase ;
1820
1921/// We're indexing many crates.
2022#[ derive( Debug ) ]
@@ -93,7 +95,7 @@ pub(crate) fn parallel_prime_caches(
9395 let mut crates_currently_indexing =
9496 FxIndexMap :: with_capacity_and_hasher ( num_worker_threads as _ , Default :: default ( ) ) ;
9597
96- while !crates_to_prime . is_empty ( ) {
98+ while crates_done < crates_total {
9799 db. unwind_if_cancelled ( ) ;
98100
99101 for crate_id in & mut crates_to_prime {
@@ -105,9 +107,14 @@ pub(crate) fn parallel_prime_caches(
105107 . ok ( ) ;
106108 }
107109
108- let worker_progress = match progress_receiver. recv ( ) {
110+ // recv_timeout is somewhat a hack, we need a way to from this thread check to see if the current salsa revision
111+ // is cancelled.
112+ let worker_progress = match progress_receiver. recv_timeout ( Duration :: from_millis ( 10 ) ) {
109113 Ok ( p) => p,
110- Err ( _) => {
114+ Err ( crossbeam_channel:: RecvTimeoutError :: Timeout ) => {
115+ continue ;
116+ }
117+ Err ( crossbeam_channel:: RecvTimeoutError :: Disconnected ) => {
111118 // our workers may have died from a cancelled task, so we'll check and re-raise here.
112119 db. unwind_if_cancelled ( ) ;
113120 break ;
0 commit comments