mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Merge #8693
8693: Ensure that only one cache priming task can run at a time r=matklad a=Bobo1239 Fixes #8632. Co-authored-by: Boris-Chengbiao Zhou <bobo1239@web.de>
This commit is contained in:
commit
548c18c062
2 changed files with 18 additions and 0 deletions
|
@ -84,6 +84,7 @@ pub(crate) struct GlobalState {
|
||||||
pub(crate) workspace_build_data: Option<BuildDataResult>,
|
pub(crate) workspace_build_data: Option<BuildDataResult>,
|
||||||
pub(crate) fetch_build_data_queue:
|
pub(crate) fetch_build_data_queue:
|
||||||
OpQueue<BuildDataCollector, Option<anyhow::Result<BuildDataResult>>>,
|
OpQueue<BuildDataCollector, Option<anyhow::Result<BuildDataResult>>>,
|
||||||
|
pub(crate) prime_caches_queue: OpQueue<(), ()>,
|
||||||
|
|
||||||
latest_requests: Arc<RwLock<LatestRequests>>,
|
latest_requests: Arc<RwLock<LatestRequests>>,
|
||||||
}
|
}
|
||||||
|
@ -146,6 +147,7 @@ impl GlobalState {
|
||||||
workspaces: Arc::new(Vec::new()),
|
workspaces: Arc::new(Vec::new()),
|
||||||
fetch_workspaces_queue: OpQueue::default(),
|
fetch_workspaces_queue: OpQueue::default(),
|
||||||
workspace_build_data: None,
|
workspace_build_data: None,
|
||||||
|
prime_caches_queue: OpQueue::default(),
|
||||||
|
|
||||||
fetch_build_data_queue: OpQueue::default(),
|
fetch_build_data_queue: OpQueue::default(),
|
||||||
latest_requests: Default::default(),
|
latest_requests: Default::default(),
|
||||||
|
|
|
@ -278,6 +278,8 @@ impl GlobalState {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut finished = false;
|
||||||
|
|
||||||
for progress in prime_caches_progress {
|
for progress in prime_caches_progress {
|
||||||
let (state, message, fraction);
|
let (state, message, fraction);
|
||||||
match progress {
|
match progress {
|
||||||
|
@ -295,11 +297,18 @@ impl GlobalState {
|
||||||
state = Progress::End;
|
state = Progress::End;
|
||||||
message = None;
|
message = None;
|
||||||
fraction = 1.0;
|
fraction = 1.0;
|
||||||
|
finished = true;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report_progress("Indexing", state, message, Some(fraction));
|
self.report_progress("Indexing", state, message, Some(fraction));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the task is cancelled we may observe two `PrimeCachesProgress::Finished` so we
|
||||||
|
// have to make sure to only call `op_completed()` once.
|
||||||
|
if finished {
|
||||||
|
self.prime_caches_queue.op_completed(());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Event::Vfs(mut task) => {
|
Event::Vfs(mut task) => {
|
||||||
let _p = profile::span("GlobalState::handle_event/vfs");
|
let _p = profile::span("GlobalState::handle_event/vfs");
|
||||||
|
@ -711,6 +720,13 @@ impl GlobalState {
|
||||||
}
|
}
|
||||||
fn update_file_notifications_on_threadpool(&mut self) {
|
fn update_file_notifications_on_threadpool(&mut self) {
|
||||||
self.maybe_update_diagnostics();
|
self.maybe_update_diagnostics();
|
||||||
|
|
||||||
|
// Ensure that only one cache priming task can run at a time
|
||||||
|
self.prime_caches_queue.request_op(());
|
||||||
|
if self.prime_caches_queue.should_start_op().is_none() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self.task_pool.handle.spawn_with_sender({
|
self.task_pool.handle.spawn_with_sender({
|
||||||
let snap = self.snapshot();
|
let snap = self.snapshot();
|
||||||
move |sender| {
|
move |sender| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue