diff --git a/src/memoized.rs b/src/derived.rs similarity index 95% rename from src/memoized.rs rename to src/derived.rs index 294a133e..ed070a44 100644 --- a/src/memoized.rs +++ b/src/derived.rs @@ -24,19 +24,21 @@ use std::marker::PhantomData; /// Memoized queries store the result plus a list of the other queries /// that they invoked. This means we can avoid recomputing them when /// none of those inputs have changed. -pub type MemoizedStorage = WeakMemoizedStorage; +pub type MemoizedStorage = DerivedStorage; /// "Dependency" queries just track their dependencies and not the /// actual value (which they produce on demand). This lessens the /// storage requirements. -pub type DependencyStorage = WeakMemoizedStorage; +pub type DependencyStorage = DerivedStorage; /// "Dependency" queries just track their dependencies and not the /// actual value (which they produce on demand). This lessens the /// storage requirements. -pub type VolatileStorage = WeakMemoizedStorage; +pub type VolatileStorage = DerivedStorage; -pub struct WeakMemoizedStorage +/// Handles storage where the value is 'derived' by executing a +/// function (in contrast to "inputs"). +pub struct DerivedStorage where Q: QueryFunction, DB: Database, @@ -138,21 +140,21 @@ where verified_at: Revision, } -impl Default for WeakMemoizedStorage +impl Default for DerivedStorage where Q: QueryFunction, DB: Database, MP: MemoizationPolicy, { fn default() -> Self { - WeakMemoizedStorage { + DerivedStorage { map: RwLock::new(FxHashMap::default()), policy: PhantomData, } } } -impl WeakMemoizedStorage +impl DerivedStorage where Q: QueryFunction, DB: Database, @@ -311,7 +313,7 @@ where } } -impl QueryStorageOps for WeakMemoizedStorage +impl QueryStorageOps for DerivedStorage where Q: QueryFunction, DB: Database, @@ -392,7 +394,7 @@ where } } -impl UncheckedMutQueryStorageOps for WeakMemoizedStorage +impl UncheckedMutQueryStorageOps for DerivedStorage where Q: QueryFunction, DB: Database, diff --git a/src/lib.rs b/src/lib.rs index 5a759640..ec136f41 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,8 +16,8 @@ use std::fmt::Display; use std::fmt::Write; use std::hash::Hash; +pub mod derived; pub mod input; -pub mod memoized; pub mod runtime; /// The base trait which your "query context" must implement. Gives @@ -421,19 +421,19 @@ macro_rules! query_group { ( @storage_ty[$DB:ident, $Self:ident, memoized] ) => { - $crate::memoized::MemoizedStorage<$DB, $Self> + $crate::derived::MemoizedStorage<$DB, $Self> }; ( @storage_ty[$DB:ident, $Self:ident, volatile] ) => { - $crate::memoized::VolatileStorage<$DB, $Self> + $crate::derived::VolatileStorage<$DB, $Self> }; ( @storage_ty[$DB:ident, $Self:ident, dependencies] ) => { - $crate::memoized::DependencyStorage<$DB, $Self> + $crate::derived::DependencyStorage<$DB, $Self> }; (