2901: Cancel requests during shutdown r=matklad a=matklad



Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
bors[bot] 2020-01-24 15:37:11 +00:00 committed by GitHub
commit c6dbf406a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 5 deletions

View file

@ -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 {

View file

@ -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) {

View file

@ -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)