mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-22 21:05:11 +00:00
Provide public API to get IngredientIndex
This commit is contained in:
parent
d4a94fbf07
commit
59f094f512
7 changed files with 28 additions and 1 deletions
|
@ -103,6 +103,10 @@ where
|
|||
DB: crate::Database,
|
||||
Data: Clone,
|
||||
{
|
||||
fn ingredient_index(&self) -> IngredientIndex {
|
||||
self.index
|
||||
}
|
||||
|
||||
fn maybe_changed_after(&self, _db: &DB, _input: DependencyIndex, _revision: Revision) -> bool {
|
||||
panic!("nothing should ever depend on an accumulator directly")
|
||||
}
|
||||
|
|
|
@ -213,6 +213,10 @@ where
|
|||
DB: ?Sized + DbWithJar<C::Jar>,
|
||||
C: Configuration,
|
||||
{
|
||||
fn ingredient_index(&self) -> IngredientIndex {
|
||||
self.index
|
||||
}
|
||||
|
||||
fn maybe_changed_after(&self, db: &DB, input: DependencyIndex, revision: Revision) -> bool {
|
||||
let key = C::key_from_id(input.key_index.unwrap());
|
||||
let db = db.as_jar_db();
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::fmt;
|
|||
|
||||
use crate::{
|
||||
cycle::CycleRecoveryStrategy, key::DependencyIndex, runtime::local_state::QueryOrigin,
|
||||
DatabaseKeyIndex, Id,
|
||||
DatabaseKeyIndex, Id, IngredientIndex,
|
||||
};
|
||||
|
||||
use super::Revision;
|
||||
|
@ -17,6 +17,9 @@ use super::Revision;
|
|||
/// [`IngredientsFor`](`crate::storage::IngredientsFor`) implementations generated by the
|
||||
/// macro.
|
||||
pub trait Ingredient<DB: ?Sized> {
|
||||
/// Returns the [`IngredientIndex`] of this ingredient.
|
||||
fn ingredient_index(&self) -> IngredientIndex;
|
||||
|
||||
/// If this ingredient is a participant in a cycle, what is its cycle recovery strategy?
|
||||
/// (Really only relevant to [`crate::function::FunctionIngredient`],
|
||||
/// since only function ingredients push themselves onto the active query stack.)
|
||||
|
|
|
@ -68,6 +68,10 @@ impl<DB: ?Sized, Id> Ingredient<DB> for InputIngredient<Id>
|
|||
where
|
||||
Id: InputId,
|
||||
{
|
||||
fn ingredient_index(&self) -> IngredientIndex {
|
||||
self.ingredient_index
|
||||
}
|
||||
|
||||
fn maybe_changed_after(&self, _db: &DB, _input: DependencyIndex, _revision: Revision) -> bool {
|
||||
// Input ingredients are just a counter, they store no data, they are immortal.
|
||||
// Their *fields* are stored in function ingredients elsewhere.
|
||||
|
|
|
@ -116,6 +116,10 @@ impl<DB: ?Sized, K, F> Ingredient<DB> for InputFieldIngredient<K, F>
|
|||
where
|
||||
K: AsId,
|
||||
{
|
||||
fn ingredient_index(&self) -> IngredientIndex {
|
||||
self.index
|
||||
}
|
||||
|
||||
fn cycle_recovery_strategy(&self) -> CycleRecoveryStrategy {
|
||||
CycleRecoveryStrategy::Panic
|
||||
}
|
||||
|
|
|
@ -194,6 +194,10 @@ where
|
|||
Id: InternedId,
|
||||
Data: InternedData,
|
||||
{
|
||||
fn ingredient_index(&self) -> IngredientIndex {
|
||||
self.ingredient_index
|
||||
}
|
||||
|
||||
fn maybe_changed_after(&self, _db: &DB, _input: DependencyIndex, revision: Revision) -> bool {
|
||||
revision < self.reset_at
|
||||
}
|
||||
|
|
|
@ -137,6 +137,10 @@ where
|
|||
Data: TrackedStructData,
|
||||
DB: crate::Database,
|
||||
{
|
||||
fn ingredient_index(&self) -> IngredientIndex {
|
||||
self.interned.ingredient_index()
|
||||
}
|
||||
|
||||
fn maybe_changed_after(&self, db: &DB, input: DependencyIndex, revision: Revision) -> bool {
|
||||
self.interned.maybe_changed_after(db, input, revision)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue