diff --git a/components/salsa-2022/src/accumulator.rs b/components/salsa-2022/src/accumulator.rs index fcae3d0..2274a37 100644 --- a/components/salsa-2022/src/accumulator.rs +++ b/components/salsa-2022/src/accumulator.rs @@ -120,7 +120,7 @@ where output_key: Option, ) { assert!(output_key.is_none()); - let current_revision = db.salsa_runtime().current_revision(); + let current_revision = db.runtime().current_revision(); if let Some(mut v) = self.map.get_mut(&executor) { // The value is still valid in the new revision. v.produced_at = current_revision; @@ -136,7 +136,7 @@ where assert!(stale_output_key.is_none()); if self.map.remove(&executor).is_some() { db.salsa_event(Event { - runtime_id: db.salsa_runtime().id(), + runtime_id: db.runtime().id(), kind: EventKind::DidDiscardAccumulated { executor_key: executor, accumulator: self.dependency_index(), diff --git a/components/salsa-2022/src/database.rs b/components/salsa-2022/src/database.rs index 3ecdae2..ff6cd8d 100644 --- a/components/salsa-2022/src/database.rs +++ b/components/salsa-2022/src/database.rs @@ -1,4 +1,4 @@ -use crate::{storage::HasJarsDyn, DebugWithDb, Event, Runtime}; +use crate::{storage::HasJarsDyn, DebugWithDb, Event}; pub trait Database: HasJarsDyn + AsSalsaDatabase { /// This function is invoked at key points in the salsa @@ -10,10 +10,6 @@ pub trait Database: HasJarsDyn + AsSalsaDatabase { fn salsa_event(&self, event: Event) { log::debug!("salsa_event: {:?}", event.debug(self)); } - - fn salsa_runtime(&self) -> &Runtime { - self.runtime() - } } /// Indicates a database that also supports parallel query diff --git a/components/salsa-2022/src/event.rs b/components/salsa-2022/src/event.rs index 0137664..fdbef71 100644 --- a/components/salsa-2022/src/event.rs +++ b/components/salsa-2022/src/event.rs @@ -56,7 +56,7 @@ pub enum EventKind { /// before they have answered us. /// /// (NB: you can find the `id` of the current thread via the - /// `salsa_runtime`) + /// `runtime`) WillBlockOn { /// The id of the runtime we will block on. other_runtime_id: RuntimeId, diff --git a/components/salsa-2022/src/function.rs b/components/salsa-2022/src/function.rs index f88187b..3123c63 100644 --- a/components/salsa-2022/src/function.rs +++ b/components/salsa-2022/src/function.rs @@ -261,7 +261,7 @@ where if let Some(origin) = self.delete_memo(id) { let key = self.database_key_index(id); db.salsa_event(Event { - runtime_id: db.salsa_runtime().id(), + runtime_id: db.runtime().id(), kind: EventKind::DidDiscard { key }, }); diff --git a/components/salsa-2022/src/function/accumulated.rs b/components/salsa-2022/src/function/accumulated.rs index df3effc..58ef6ee 100644 --- a/components/salsa-2022/src/function/accumulated.rs +++ b/components/salsa-2022/src/function/accumulated.rs @@ -3,7 +3,7 @@ use crate::{ key::DependencyIndex, runtime::local_state::QueryOrigin, storage::{HasJar, HasJarsDyn}, - Database, DatabaseKeyIndex, + DatabaseKeyIndex, }; use super::{Configuration, DynDb, FunctionIngredient}; @@ -26,7 +26,7 @@ where // Now walk over all the things that the value depended on // and find the values they accumulated into the given // accumulator: - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); let mut result = vec![]; let accumulator_ingredient = A::accumulator_ingredient(db); let mut stack = Stack::new(self.database_key_index(key)); diff --git a/components/salsa-2022/src/function/diff_outputs.rs b/components/salsa-2022/src/function/diff_outputs.rs index cb989fe..73e3b09 100644 --- a/components/salsa-2022/src/function/diff_outputs.rs +++ b/components/salsa-2022/src/function/diff_outputs.rs @@ -45,7 +45,7 @@ where } fn report_stale_output(db: &DynDb<'_, C>, key: DatabaseKeyIndex, output: DependencyIndex) { - let runtime_id = db.salsa_runtime().id(); + let runtime_id = db.runtime().id(); db.salsa_event(Event { runtime_id, kind: EventKind::WillDiscardStaleOutput { diff --git a/components/salsa-2022/src/function/execute.rs b/components/salsa-2022/src/function/execute.rs index a70b7d6..c073598 100644 --- a/components/salsa-2022/src/function/execute.rs +++ b/components/salsa-2022/src/function/execute.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use crate::{ debug::DebugWithDb, runtime::{local_state::ActiveQueryGuard, StampedValue}, + storage::HasJarsDyn, Cycle, Database, Event, EventKind, }; @@ -27,7 +28,7 @@ where active_query: ActiveQueryGuard<'_>, opt_old_memo: Option>>, ) -> StampedValue<&C::Value> { - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); let revision_now = runtime.current_revision(); let database_key_index = active_query.database_key_index; diff --git a/components/salsa-2022/src/function/fetch.rs b/components/salsa-2022/src/function/fetch.rs index 1bbda7a..384b381 100644 --- a/components/salsa-2022/src/function/fetch.rs +++ b/components/salsa-2022/src/function/fetch.rs @@ -1,6 +1,6 @@ use arc_swap::Guard; -use crate::{database::AsSalsaDatabase, runtime::StampedValue, AsId, Database}; +use crate::{database::AsSalsaDatabase, runtime::StampedValue, storage::HasJarsDyn, AsId}; use super::{Configuration, DynDb, FunctionIngredient}; @@ -9,7 +9,7 @@ where C: Configuration, { pub fn fetch(&self, db: &DynDb, key: C::Key) -> &C::Value { - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); runtime.unwind_if_revision_cancelled(db); @@ -23,7 +23,7 @@ where self.evict(AsId::from_id(evicted)); } - db.salsa_runtime().report_tracked_read( + db.runtime().report_tracked_read( self.database_key_index(key).into(), durability, changed_at, @@ -46,7 +46,7 @@ where let memo_guard = self.memo_map.get(key); if let Some(memo) = &memo_guard { if memo.value.is_some() { - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); if self.shallow_verify_memo(db, runtime, self.database_key_index(key), memo) { let value = unsafe { // Unsafety invariant: memo is present in memo_map @@ -60,7 +60,7 @@ where } fn fetch_cold(&self, db: &DynDb, key: C::Key) -> Option> { - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); let database_key_index = self.database_key_index(key); // Try to claim this query: if someone else has claimed it already, go back and start again. diff --git a/components/salsa-2022/src/function/maybe_changed_after.rs b/components/salsa-2022/src/function/maybe_changed_after.rs index 9f64e1d..2888b45 100644 --- a/components/salsa-2022/src/function/maybe_changed_after.rs +++ b/components/salsa-2022/src/function/maybe_changed_after.rs @@ -9,7 +9,7 @@ use crate::{ StampedValue, }, storage::HasJarsDyn, - Database, Revision, Runtime, + Revision, Runtime, }; use super::{memo::Memo, Configuration, DynDb, FunctionIngredient}; @@ -24,7 +24,7 @@ where key: C::Key, revision: Revision, ) -> bool { - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); runtime.unwind_if_revision_cancelled(db); loop { @@ -61,7 +61,7 @@ where key_index: C::Key, revision: Revision, ) -> Option { - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); let database_key_index = self.database_key_index(key_index); let _claim_guard = self @@ -148,7 +148,7 @@ where old_memo: &Memo, active_query: &ActiveQueryGuard<'_>, ) -> bool { - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); let database_key_index = active_query.database_key_index; log::debug!( diff --git a/components/salsa-2022/src/function/specify.rs b/components/salsa-2022/src/function/specify.rs index 1769b00..6de87ad 100644 --- a/components/salsa-2022/src/function/specify.rs +++ b/components/salsa-2022/src/function/specify.rs @@ -3,8 +3,9 @@ use crossbeam::atomic::AtomicCell; use crate::{ database::AsSalsaDatabase, runtime::local_state::{QueryOrigin, QueryRevisions}, + storage::HasJarsDyn, tracked_struct::TrackedStructInDb, - Database, DatabaseKeyIndex, DebugWithDb, + DatabaseKeyIndex, DebugWithDb, }; use super::{memo::Memo, Configuration, DynDb, FunctionIngredient}; @@ -25,7 +26,7 @@ where ) where C::Key: TrackedStructInDb>, { - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); let (active_query_key, current_deps) = match runtime.active_query() { Some(v) => v, @@ -101,7 +102,7 @@ where // Record that the current query *specified* a value for this cell. let database_key_index = self.database_key_index(key); - db.salsa_runtime().add_output(database_key_index.into()); + db.runtime().add_output(database_key_index.into()); } /// Invoked when the query `executor` has been validated as having green inputs @@ -114,7 +115,7 @@ where executor: DatabaseKeyIndex, key: C::Key, ) { - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); let memo = match self.memo_map.get(key) { Some(m) => m, diff --git a/components/salsa-2022/src/function/sync.rs b/components/salsa-2022/src/function/sync.rs index e3a8e7b..aa63e3d 100644 --- a/components/salsa-2022/src/function/sync.rs +++ b/components/salsa-2022/src/function/sync.rs @@ -26,7 +26,7 @@ impl SyncMap { db: &'me dyn Database, database_key_index: DatabaseKeyIndex, ) -> Option> { - let runtime = db.salsa_runtime(); + let runtime = db.runtime(); match self.sync_map.entry(database_key_index.key_index) { dashmap::mapref::entry::Entry::Vacant(entry) => { entry.insert(SyncState { diff --git a/components/salsa-2022/src/tracked_struct.rs b/components/salsa-2022/src/tracked_struct.rs index 9f74909..f66d1f6 100644 --- a/components/salsa-2022/src/tracked_struct.rs +++ b/components/salsa-2022/src/tracked_struct.rs @@ -111,7 +111,7 @@ where /// discussion and important considerations. pub(crate) fn delete_entity(&self, db: &dyn crate::Database, id: Id) { db.salsa_event(Event { - runtime_id: db.salsa_runtime().id(), + runtime_id: db.runtime().id(), kind: crate::EventKind::DidDiscard { key: self.database_key_index(id), }, diff --git a/salsa-2022-tests/tests/lru.rs b/salsa-2022-tests/tests/lru.rs index 75d95a2..8269ac4 100644 --- a/salsa-2022-tests/tests/lru.rs +++ b/salsa-2022-tests/tests/lru.rs @@ -55,7 +55,7 @@ fn get_hot_potato2(db: &dyn Db, input: MyInput) -> u32 { #[salsa::tracked(jar = Jar, lru = 32)] fn get_volatile(db: &dyn Db, _input: MyInput) -> usize { static COUNTER: AtomicUsize = AtomicUsize::new(0); - db.salsa_runtime().report_untracked_read(); + db.runtime().report_untracked_read(); COUNTER.fetch_add(1, Ordering::SeqCst) }