File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,7 @@ pub(crate) struct GlobalState {
84
84
pub ( crate ) workspace_build_data : Option < BuildDataResult > ,
85
85
pub ( crate ) fetch_build_data_queue :
86
86
OpQueue < BuildDataCollector , Option < anyhow:: Result < BuildDataResult > > > ,
87
+ pub ( crate ) prime_caches_queue : OpQueue < ( ) , ( ) > ,
87
88
88
89
latest_requests : Arc < RwLock < LatestRequests > > ,
89
90
}
@@ -146,6 +147,7 @@ impl GlobalState {
146
147
workspaces : Arc :: new ( Vec :: new ( ) ) ,
147
148
fetch_workspaces_queue : OpQueue :: default ( ) ,
148
149
workspace_build_data : None ,
150
+ prime_caches_queue : OpQueue :: default ( ) ,
149
151
150
152
fetch_build_data_queue : OpQueue :: default ( ) ,
151
153
latest_requests : Default :: default ( ) ,
Original file line number Diff line number Diff line change @@ -278,6 +278,8 @@ impl GlobalState {
278
278
} ;
279
279
}
280
280
281
+ let mut finished = false ;
282
+
281
283
for progress in prime_caches_progress {
282
284
let ( state, message, fraction) ;
283
285
match progress {
@@ -295,11 +297,18 @@ impl GlobalState {
295
297
state = Progress :: End ;
296
298
message = None ;
297
299
fraction = 1.0 ;
300
+ finished = true ;
298
301
}
299
302
} ;
300
303
301
304
self . report_progress ( "Indexing" , state, message, Some ( fraction) ) ;
302
305
}
306
+
307
+ // If the task is cancelled we may observe two `PrimeCachesProgress::Finished` so we
308
+ // have to make sure to only call `op_completed()` once.
309
+ if finished {
310
+ self . prime_caches_queue . op_completed ( ( ) ) ;
311
+ }
303
312
}
304
313
Event :: Vfs ( mut task) => {
305
314
let _p = profile:: span ( "GlobalState::handle_event/vfs" ) ;
@@ -711,6 +720,13 @@ impl GlobalState {
711
720
}
712
721
fn update_file_notifications_on_threadpool ( & mut self ) {
713
722
self . maybe_update_diagnostics ( ) ;
723
+
724
+ // Ensure that only one cache priming task can run at a time
725
+ self . prime_caches_queue . request_op ( ( ) ) ;
726
+ if self . prime_caches_queue . should_start_op ( ) . is_none ( ) {
727
+ return ;
728
+ }
729
+
714
730
self . task_pool . handle . spawn_with_sender ( {
715
731
let snap = self . snapshot ( ) ;
716
732
move |sender| {
You can’t perform that action at this time.
0 commit comments