diff --git a/src/derived.rs b/src/derived.rs index 95ff907d..58fb94a4 100644 --- a/src/derived.rs +++ b/src/derived.rs @@ -209,7 +209,7 @@ where ) -> Result, CycleDetected> { let runtime = db.salsa_runtime(); - let _read_lock = runtime.freeze_revision(); + let _read_lock = runtime.start_query(); let revision_now = runtime.current_revision(); diff --git a/src/lib.rs b/src/lib.rs index d2873af4..88433ecf 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,19 +28,6 @@ pub trait Database: plumbing::DatabaseStorageTypes { /// Gives access to the underlying salsa runtime. fn salsa_runtime(&self) -> &Runtime; - /// Executes `op` while holding the "query lock". This guarantees - /// that all operations in `op` occur with one consistent database - /// revision: in particular, any attempts to `set` will block - /// until `op` returns (note that if `op` tries to invoke `set`, - /// you will get a deadlock). - /// - /// (This is the same locking mechanism used by active derived - /// queries to ensure that they have a consistent view of the - /// database.) - fn with_frozen_revision(&self, op: impl FnOnce() -> R) -> R { - self.salsa_runtime().with_frozen_revision(op) - } - /// Get access to extra methods pertaining to a given query, /// notably `set` (for inputs). #[allow(unused_variables)] diff --git a/src/runtime.rs b/src/runtime.rs index 06e957d8..caf5d66b 100644 --- a/src/runtime.rs +++ b/src/runtime.rs @@ -100,13 +100,13 @@ where /// (However, if other threads invoke `increment_revision`, then /// the current revision may be considered cancelled, which can be /// observed through `is_current_revision_canceled`.) - pub(crate) fn freeze_revision(&self) -> Option> { + pub(crate) fn start_query(&self) -> Option> { let mut local_state = self.local_state.borrow_mut(); if !local_state.query_in_progress { local_state.query_in_progress = true; let guard = self.shared_state.query_lock.read(); - Some(RevisionGuard::new(self, guard)) + Some(QueryGuard::new(self, guard)) } else { None } @@ -116,7 +116,7 @@ where /// `Database`. See the `Database` trait for more /// details. pub fn with_frozen_revision(&self, op: impl FnOnce() -> R) -> R { - let _lock = self.freeze_revision(); + let _lock = self.start_query(); op() } @@ -387,18 +387,18 @@ impl Default for LocalState { } } -pub(crate) struct RevisionGuard<'db, DB: Database + 'db> { +pub(crate) struct QueryGuard<'db, DB: Database + 'db> { db: &'db Runtime, lock: RwLockReadGuard<'db, ()>, } -impl<'db, DB: Database> RevisionGuard<'db, DB> { +impl<'db, DB: Database> QueryGuard<'db, DB> { fn new(db: &'db Runtime, lock: RwLockReadGuard<'db, ()>) -> Self { Self { db, lock } } } -impl<'db, DB: Database> Drop for RevisionGuard<'db, DB> { +impl<'db, DB: Database> Drop for QueryGuard<'db, DB> { fn drop(&mut self) { let mut local_state = self.db.local_state.borrow_mut(); assert!(local_state.query_in_progress);