From 9229b1a23a74a666cd46f0b06bc2ff59d6665a70 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 7 Aug 2022 23:35:43 -0400 Subject: [PATCH] rename Ingredients to Routes The old name makes it sound like it contains the actual ingredients, but really it just contains the routes we use to find them at runtime. --- .../salsa-2022-macros/src/accumulator.rs | 4 ++-- components/salsa-2022-macros/src/db.rs | 4 ++-- components/salsa-2022-macros/src/input.rs | 6 ++--- components/salsa-2022-macros/src/interned.rs | 4 ++-- components/salsa-2022-macros/src/jar.rs | 4 ++-- .../salsa-2022-macros/src/tracked_fn.rs | 6 ++--- .../salsa-2022-macros/src/tracked_struct.rs | 6 ++--- components/salsa-2022/src/ingredient.rs | 2 +- components/salsa-2022/src/jar.rs | 4 ++-- components/salsa-2022/src/routes.rs | 10 ++++----- components/salsa-2022/src/storage.rs | 22 +++++++++---------- 11 files changed, 36 insertions(+), 36 deletions(-) diff --git a/components/salsa-2022-macros/src/accumulator.rs b/components/salsa-2022-macros/src/accumulator.rs index 266f3ac3..8b1eddae 100644 --- a/components/salsa-2022-macros/src/accumulator.rs +++ b/components/salsa-2022-macros/src/accumulator.rs @@ -112,11 +112,11 @@ fn ingredients_for_impl(args: &Args, struct_ty: &syn::Type, data_ty: &syn::Type) type Ingredients = salsa::accumulator::AccumulatorIngredient<#data_ty>; type Jar = #jar_ty; - fn create_ingredients(ingredients: &mut salsa::routes::Ingredients) -> Self::Ingredients + fn create_ingredients(routes: &mut salsa::routes::Routes) -> Self::Ingredients where DB: salsa::DbWithJar + salsa::storage::JarFromJars, { - let index = ingredients.push_mut( + let index = routes.push_mut( |jars| { let jar = >::jar_from_jars(jars); <_ as salsa::storage::HasIngredientsFor>::ingredient(jar) diff --git a/components/salsa-2022-macros/src/db.rs b/components/salsa-2022-macros/src/db.rs index 19200f99..94c729ef 100644 --- a/components/salsa-2022-macros/src/db.rs +++ b/components/salsa-2022-macros/src/db.rs @@ -97,10 +97,10 @@ fn has_jars_impl(args: &Args, input: &syn::ItemStruct, storage: &syn::Ident) -> self.#storage.jars_mut() } - fn create_jars(ingredients: &mut salsa::routes::Ingredients) -> Self::Jars { + fn create_jars(routes: &mut salsa::routes::Routes) -> Self::Jars { ( #( - <#jar_paths as salsa::jar::Jar>::create_jar(ingredients), + <#jar_paths as salsa::jar::Jar>::create_jar(routes), )* ) } diff --git a/components/salsa-2022-macros/src/input.rs b/components/salsa-2022-macros/src/input.rs index 127ba125..4067a5c6 100644 --- a/components/salsa-2022-macros/src/input.rs +++ b/components/salsa-2022-macros/src/input.rs @@ -133,7 +133,7 @@ impl SalsaStruct { ); fn create_ingredients( - ingredients: &mut salsa::routes::Ingredients, + routes: &mut salsa::routes::Routes, ) -> Self::Ingredients where DB: salsa::DbWithJar + salsa::storage::JarFromJars, @@ -141,7 +141,7 @@ impl SalsaStruct { ( #( { - let index = ingredients.push( + let index = routes.push( |jars| { let jar = >::jar_from_jars(jars); let ingredients = <_ as salsa::storage::HasIngredientsFor>::ingredient(jar); @@ -152,7 +152,7 @@ impl SalsaStruct { }, )* { - let index = ingredients.push( + let index = routes.push( |jars| { let jar = >::jar_from_jars(jars); let ingredients = <_ as salsa::storage::HasIngredientsFor>::ingredient(jar); diff --git a/components/salsa-2022-macros/src/interned.rs b/components/salsa-2022-macros/src/interned.rs index a2ed412e..af2a1a43 100644 --- a/components/salsa-2022-macros/src/interned.rs +++ b/components/salsa-2022-macros/src/interned.rs @@ -114,12 +114,12 @@ impl SalsaStruct { type Ingredients = salsa::interned::InternedIngredient<#id_ident, #data_ident>; fn create_ingredients( - ingredients: &mut salsa::routes::Ingredients, + routes: &mut salsa::routes::Routes, ) -> Self::Ingredients where DB: salsa::storage::JarFromJars, { - let index = ingredients.push( + let index = routes.push( |jars| { let jar = >::jar_from_jars(jars); <_ as salsa::storage::HasIngredientsFor>::ingredient(jar) diff --git a/components/salsa-2022-macros/src/jar.rs b/components/salsa-2022-macros/src/jar.rs index 923ecc17..7a6498d4 100644 --- a/components/salsa-2022-macros/src/jar.rs +++ b/components/salsa-2022-macros/src/jar.rs @@ -106,12 +106,12 @@ pub(crate) fn jar_impl( impl<'salsa_db> salsa::jar::Jar<'salsa_db> for #jar_struct { type DynDb = dyn #jar_trait + 'salsa_db; - fn create_jar(ingredients: &mut salsa::routes::Ingredients) -> Self + fn create_jar(routes: &mut salsa::routes::Routes) -> Self where DB: salsa::storage::JarFromJars + salsa::storage::DbWithJar, { #( - let #field_var_names = <#field_tys as salsa::storage::IngredientsFor>::create_ingredients(ingredients); + let #field_var_names = <#field_tys as salsa::storage::IngredientsFor>::create_ingredients(routes); )* Self(#(#field_var_names),*) } diff --git a/components/salsa-2022-macros/src/tracked_fn.rs b/components/salsa-2022-macros/src/tracked_fn.rs index f22dd213..bcb9172f 100644 --- a/components/salsa-2022-macros/src/tracked_fn.rs +++ b/components/salsa-2022-macros/src/tracked_fn.rs @@ -206,7 +206,7 @@ fn ingredients_for_impl( let intern_map: syn::Expr = if requires_interning(item_fn) { parse_quote! { { - let index = ingredients.push(|jars| { + let index = routes.push(|jars| { let jar = >::jar_from_jars(jars); let ingredients = <_ as salsa::storage::HasIngredientsFor>::ingredient(jar); @@ -226,7 +226,7 @@ fn ingredients_for_impl( type Ingredients = Self; type Jar = #jar_ty; - fn create_ingredients(ingredients: &mut salsa::routes::Ingredients) -> Self::Ingredients + fn create_ingredients(routes: &mut salsa::routes::Routes) -> Self::Ingredients where DB: salsa::DbWithJar + salsa::storage::JarFromJars, { @@ -234,7 +234,7 @@ fn ingredients_for_impl( intern_map: #intern_map, function: { - let index = ingredients.push(|jars| { + let index = routes.push(|jars| { let jar = >::jar_from_jars(jars); let ingredients = <_ as salsa::storage::HasIngredientsFor>::ingredient(jar); diff --git a/components/salsa-2022-macros/src/tracked_struct.rs b/components/salsa-2022-macros/src/tracked_struct.rs index b4ae2ddc..7c70fa52 100644 --- a/components/salsa-2022-macros/src/tracked_struct.rs +++ b/components/salsa-2022-macros/src/tracked_struct.rs @@ -154,7 +154,7 @@ impl SalsaStruct { ); fn create_ingredients( - ingredients: &mut salsa::routes::Ingredients, + routes: &mut salsa::routes::Routes, ) -> Self::Ingredients where DB: salsa::DbWithJar + salsa::storage::JarFromJars, @@ -162,7 +162,7 @@ impl SalsaStruct { ( #( { - let index = ingredients.push( + let index = routes.push( |jars| { let jar = >::jar_from_jars(jars); let ingredients = <_ as salsa::storage::HasIngredientsFor>::ingredient(jar); @@ -173,7 +173,7 @@ impl SalsaStruct { }, )* { - let index = ingredients.push_mut( + let index = routes.push_mut( |jars| { let jar = >::jar_from_jars(jars); let ingredients = <_ as salsa::storage::HasIngredientsFor>::ingredient(jar); diff --git a/components/salsa-2022/src/ingredient.rs b/components/salsa-2022/src/ingredient.rs index f7843f93..0b321c26 100644 --- a/components/salsa-2022/src/ingredient.rs +++ b/components/salsa-2022/src/ingredient.rs @@ -26,7 +26,7 @@ pub trait Ingredient { /// Optional trait for ingredients that wish to be notified when new revisions are /// about to occur. If ingredients wish to receive these method calls, -/// they need to indicate that by invoking [`Ingredients::push_mut`] during initialization. +/// they need to indicate that by invoking [`Routes::push_mut`] during initialization. pub trait MutIngredient: Ingredient { /// Invoked when a new revision is about to start. This gives ingredients /// a chance to flush data and so forth. diff --git a/components/salsa-2022/src/jar.rs b/components/salsa-2022/src/jar.rs index 8129ef47..36c41eb0 100644 --- a/components/salsa-2022/src/jar.rs +++ b/components/salsa-2022/src/jar.rs @@ -3,12 +3,12 @@ use crate::{ Database, DbWithJar, }; -use super::routes::Ingredients; +use super::routes::Routes; pub trait Jar<'db>: Sized { type DynDb: ?Sized + HasJar + Database + 'db; - fn create_jar(ingredients: &mut Ingredients) -> Self + fn create_jar(routes: &mut Routes) -> Self where DB: JarFromJars + DbWithJar; } diff --git a/components/salsa-2022/src/routes.rs b/components/salsa-2022/src/routes.rs index ebdd8ea9..308f7217 100644 --- a/components/salsa-2022/src/routes.rs +++ b/components/salsa-2022/src/routes.rs @@ -41,14 +41,14 @@ pub type DynRoute = dyn Fn(&DB::Jars) -> (&dyn Ingredient) + Se pub type DynMutRoute = dyn Fn(&mut DB::Jars) -> (&mut dyn MutIngredient) + Send + Sync; -/// The "ingredients" structure is used to navigate the database. +/// The "routes" structure is used to navigate the database. /// The database contains a number of jars, and each jar contains a number of ingredients. /// When the database is created, it creates each jar in turn. /// Each jar then creates its ingredients. -/// Each ingredient is registered with the database by invoking the [`Ingredients::push`] method. +/// Each ingredient is registered with the database by invoking the [`Routes::push`] method. /// This method assigns it a unique [`IngredientIndex`] and stores some callbacks indicating /// how to find the ingredient later based only on the index. -pub struct Ingredients { +pub struct Routes { /// Vector indexed by ingredient index. Yields the `DynRoute`, /// a function which can be applied to the `DB::Jars` to yield /// the `dyn Ingredient. @@ -61,10 +61,10 @@ pub struct Ingredients { mut_routes: Vec>>, } -impl Ingredients { +impl Routes { /// Construct an empty ingredients listing. pub(super) fn new() -> Self { - Ingredients { + Routes { routes: vec![], mut_routes: vec![], } diff --git a/components/salsa-2022/src/storage.rs b/components/salsa-2022/src/storage.rs index e879cbb6..29926d37 100644 --- a/components/salsa-2022/src/storage.rs +++ b/components/salsa-2022/src/storage.rs @@ -10,7 +10,7 @@ use crate::runtime::local_state::QueryInputs; use crate::runtime::Runtime; use crate::{Database, DatabaseKeyIndex, IngredientIndex}; -use super::routes::Ingredients; +use super::routes::Routes; use super::{ParallelDatabase, Revision}; /// The "storage" struct stores all the data for the jars. @@ -22,7 +22,7 @@ pub struct Storage { /// The "ingredients" structure stores the information about how to find each ingredient in the database. /// It allows us to take the [`IngredientIndex`] assigned to a particular ingredient /// and get back a [`dyn Ingredient`][`Ingredient`] for the struct that stores its data. - ingredients: Arc>, + routes: Arc>, /// The runtime for this particular salsa database handle. /// Each handle gets its own runtime, but the runtimes have shared state between them.s @@ -48,14 +48,14 @@ where DB: HasJars, { fn default() -> Self { - let mut ingredients = Ingredients::new(); - let jars = DB::create_jars(&mut ingredients); + let mut routes = Routes::new(); + let jars = DB::create_jars(&mut routes); Self { shared: Arc::new(Shared { jars, cvar: Default::default(), }), - ingredients: Arc::new(ingredients), + routes: Arc::new(routes), runtime: Runtime::default(), } } @@ -71,7 +71,7 @@ where { Self { shared: self.shared.clone(), - ingredients: self.ingredients.clone(), + routes: self.routes.clone(), runtime: self.runtime.snapshot(), } } @@ -92,9 +92,9 @@ where self.cancel_other_workers(); self.runtime.new_revision(); - let ingredients = self.ingredients.clone(); + let routes = self.routes.clone(); let shared = Arc::get_mut(&mut self.shared).unwrap(); - for route in ingredients.mut_routes() { + for route in routes.mut_routes() { route(&mut shared.jars).reset_for_new_revision(); } @@ -126,7 +126,7 @@ where } pub fn ingredient(&self, ingredient_index: IngredientIndex) -> &dyn Ingredient { - let route = self.ingredients.route(ingredient_index); + let route = self.routes.route(ingredient_index); route(&self.shared.jars) } } @@ -149,7 +149,7 @@ pub trait HasJars: HasJarsDyn + Sized { /// and it will also cancel any ongoing work in the current revision. fn jars_mut(&mut self) -> (&mut Self::Jars, &mut Runtime); - fn create_jars(ingredients: &mut Ingredients) -> Self::Jars; + fn create_jars(routes: &mut Routes) -> Self::Jars; } pub trait DbWithJar: HasJar + Database { @@ -193,7 +193,7 @@ pub trait IngredientsFor { type Jar; type Ingredients; - fn create_ingredients(ingredients: &mut Ingredients) -> Self::Ingredients + fn create_ingredients(routes: &mut Routes) -> Self::Ingredients where DB: DbWithJar + JarFromJars; }