Skip to content

Commit

Permalink
cancel_all method for database
Browse files Browse the repository at this point in the history
commit-id:b7f941b4
  • Loading branch information
Draggu committed Dec 2, 2024
1 parent a83dfa9 commit 3013a6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/lang/db/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use cairo_lang_starknet::starknet_plugin_suite;
use cairo_lang_syntax::node::db::{SyntaxDatabase, SyntaxGroup};
use cairo_lang_test_plugin::test_plugin_suite;
use cairo_lang_utils::Upcast;
use salsa::{Database, Durability};

pub use self::semantic::*;
pub use self::swapper::*;
Expand Down Expand Up @@ -90,6 +91,11 @@ impl AnalysisDatabase {
CfgSet::from_iter([Cfg::kv("target", "test")])
}

/// Trigger cancellation in any background tasks that might still be running.
pub fn cancel_all(&mut self) {
self.salsa_runtime_mut().synthetic_write(Durability::LOW);
}

/// Shortcut for settings compiler plugins from a [`PluginSuite`].
fn apply_plugin_suite(&mut self, plugin_suite: PluginSuite) {
self.set_macro_plugins(plugin_suite.plugins);
Expand Down
4 changes: 1 addition & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ use cairo_lang_semantic::plugin::PluginSuite;
use crossbeam::channel::{Receiver, select_biased};
use lsp_server::Message;
use lsp_types::RegistrationParams;
use salsa::{Database, Durability};
use tracing::{debug, error, info};

use crate::lang::lsp::LsProtoGroup;
Expand Down Expand Up @@ -294,8 +293,7 @@ impl Backend {
scheduler,
);

// Trigger cancellation in any background tasks that might still be running.
state.db.salsa_runtime_mut().synthetic_write(Durability::LOW);
state.db.cancel_all();

if let Err(err) = connection.close() {
error!("failed to close connection to the language server: {err:?}");
Expand Down

0 comments on commit 3013a6d

Please sign in to comment.