4
4
//! various caches, it's not really advanced at the moment.
5
5
mod topologic_sort;
6
6
7
+ use std:: time:: Duration ;
8
+
7
9
use hir:: db:: DefDatabase ;
8
10
use ide_db:: {
9
11
base_db:: {
@@ -14,7 +16,7 @@ use ide_db::{
14
16
} ;
15
17
use rustc_hash:: FxHashSet ;
16
18
17
- use crate :: { prime_caches , RootDatabase } ;
19
+ use crate :: RootDatabase ;
18
20
19
21
/// We're indexing many crates.
20
22
#[ derive( Debug ) ]
@@ -93,7 +95,7 @@ pub(crate) fn parallel_prime_caches(
93
95
let mut crates_currently_indexing =
94
96
FxIndexMap :: with_capacity_and_hasher ( num_worker_threads as _ , Default :: default ( ) ) ;
95
97
96
- while !crates_to_prime . is_empty ( ) {
98
+ while crates_done < crates_total {
97
99
db. unwind_if_cancelled ( ) ;
98
100
99
101
for crate_id in & mut crates_to_prime {
@@ -105,9 +107,14 @@ pub(crate) fn parallel_prime_caches(
105
107
. ok ( ) ;
106
108
}
107
109
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 ) ) {
109
113
Ok ( p) => p,
110
- Err ( _) => {
114
+ Err ( crossbeam_channel:: RecvTimeoutError :: Timeout ) => {
115
+ continue ;
116
+ }
117
+ Err ( crossbeam_channel:: RecvTimeoutError :: Disconnected ) => {
111
118
// our workers may have died from a cancelled task, so we'll check and re-raise here.
112
119
db. unwind_if_cancelled ( ) ;
113
120
break ;
0 commit comments