From c76e4d7d5a0745323c65f03dd4a0bb219f117a7e Mon Sep 17 00:00:00 2001 From: David Barsky Date: Mon, 6 Jan 2025 19:33:47 -0500 Subject: [PATCH] expose `Database::unwind_if_revision_cancelled` --- src/database.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/database.rs b/src/database.rs index a978df0e..0c6867f9 100644 --- a/src/database.rs +++ b/src/database.rs @@ -54,6 +54,24 @@ pub trait Database: Send + AsDynDatabase + Any + ZalsaDatabase { ) } + /// Starts unwinding the stack if the current revision is cancelled. + /// + /// This method can be called by query implementations that perform + /// potentially expensive computations, in order to speed up propagation of + /// cancellation. + /// + /// Cancellation will automatically be triggered by salsa on any query + /// invocation. + /// + /// This method should not be overridden by `Database` implementors. A + /// `salsa_event` is emitted when this method is called, so that should be + /// used instead. + fn unwind_if_revision_cancelled(&self) { + let db = self.as_dyn_database(); + let zalsa_local = db.zalsa_local(); + zalsa_local.unwind_if_revision_cancelled(db); + } + /// Execute `op` with the database in thread-local storage for debug print-outs. fn attach(&self, op: impl FnOnce(&Self) -> R) -> R where