internal: improve consistency

Let's have only one place where we start delayed ops
This commit is contained in:
Aleksey Kladov 2021-08-30 19:24:31 +03:00
parent 6317292cd5
commit a59f344c4f

View File

@ -427,23 +427,6 @@ impl GlobalState {
if !was_quiescent || state_changed {
// 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() {
self.task_pool.handle.spawn_with_sender({
let analysis = self.snapshot().analysis;
move |sender| {
sender.send(Task::PrimeCaches(PrimeCachesProgress::Begin)).unwrap();
let res = analysis.prime_caches(|progress| {
let report = PrimeCachesProgress::Report(progress);
sender.send(Task::PrimeCaches(report)).unwrap();
});
sender
.send(Task::PrimeCaches(PrimeCachesProgress::End {
cancelled: res.is_err(),
}))
.unwrap();
}
});
}
// Refresh semantic tokens if the client supports it.
if self.config.semantic_tokens_refresh() {
@ -494,6 +477,24 @@ impl GlobalState {
}
self.fetch_build_data_if_needed();
if self.prime_caches_queue.should_start_op() {
self.task_pool.handle.spawn_with_sender({
let analysis = self.snapshot().analysis;
move |sender| {
sender.send(Task::PrimeCaches(PrimeCachesProgress::Begin)).unwrap();
let res = analysis.prime_caches(|progress| {
let report = PrimeCachesProgress::Report(progress);
sender.send(Task::PrimeCaches(report)).unwrap();
});
sender
.send(Task::PrimeCaches(PrimeCachesProgress::End {
cancelled: res.is_err(),
}))
.unwrap();
}
});
}
self.report_new_status_if_needed();
let loop_duration = loop_start.elapsed();