From b90ea640e6484788f8728be6e48cc55d90e488ba Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 24 Jan 2020 16:35:37 +0100 Subject: Cancel requests during shutdown --- crates/ra_ide/src/change.rs | 10 ++++++---- crates/ra_ide/src/lib.rs | 3 +++ crates/ra_lsp_server/src/main_loop.rs | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/crates/ra_ide/src/change.rs b/crates/ra_ide/src/change.rs index b0aa2c8e0..ce617840c 100644 --- a/crates/ra_ide/src/change.rs +++ b/crates/ra_ide/src/change.rs @@ -166,13 +166,15 @@ impl LibraryData { const GC_COOLDOWN: time::Duration = time::Duration::from_millis(100); impl RootDatabase { + pub(crate) fn request_cancellation(&mut self) { + let _p = profile("RootDatabase::request_cancellation"); + self.salsa_runtime_mut().synthetic_write(Durability::LOW); + } + pub(crate) fn apply_change(&mut self, change: AnalysisChange) { let _p = profile("RootDatabase::apply_change"); + self.request_cancellation(); log::info!("apply_change {:?}", change); - { - let _p = profile("RootDatabase::apply_change/cancellation"); - self.salsa_runtime_mut().synthetic_write(Durability::LOW); - } if !change.new_roots.is_empty() { let mut local_roots = Vec::clone(&self.local_roots()); for (root_id, is_local) in change.new_roots { diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index 4d8deb21c..62fe6d2a9 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs @@ -202,6 +202,9 @@ impl AnalysisHost { pub fn per_query_memory_usage(&mut self) -> Vec<(String, ra_prof::Bytes)> { self.db.per_query_memory_usage() } + pub fn request_cancellation(&mut self) { + self.db.request_cancellation(); + } pub fn raw_database( &self, ) -> &(impl hir::db::HirDatabase + salsa::Database + ra_db::SourceDatabaseExt) { diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 746a8fbe9..83adf9711 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -210,7 +210,7 @@ pub fn main_loop( )?; } } - + world_state.analysis_host.request_cancellation(); log::info!("waiting for tasks to finish..."); task_receiver.into_iter().for_each(|task| { on_task(task, &connection.sender, &mut loop_state.pending_requests, &mut world_state) -- cgit v1.2.3