From d134e0a54b55250d3b8c528e71ec6d0b16dc8329 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Wed, 3 Aug 2022 00:05:37 -0400 Subject: [PATCH] comment the fields on an interned ingredient --- components/salsa-entity-mock/src/interned.rs | 24 +++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/components/salsa-entity-mock/src/interned.rs b/components/salsa-entity-mock/src/interned.rs index c561ab72..f6172df4 100644 --- a/components/salsa-entity-mock/src/interned.rs +++ b/components/salsa-entity-mock/src/interned.rs @@ -21,15 +21,33 @@ impl InternedData for T {} #[allow(dead_code)] pub struct InternedIngredient { + /// Index of this ingredient in the database (used to construct database-ids, etc). ingredient_index: IngredientIndex, - // Deadlock requirement: - // - // We access `key_map` while holding lock on `value_map`, but not vice versa. + /// Maps from data to the existing interned id for that data. + /// + /// Deadlock requirement: We access `key_map` while holding lock on `value_map`, but not vice versa. key_map: FxDashMap, + + /// Maps from an interned id to its data. + /// + /// Deadlock requirement: We access `key_map` while holding lock on `value_map`, but not vice versa. value_map: FxDashMap>, + + /// counter for the next id. counter: AtomicCell, + + /// Stores the revision when this interned ingredient was last cleared. + /// You can clear an interned table at any point, deleting all its entries, + /// but that will make anything dependent on those entries dirty and in need + /// of being recomputed. reset_at: Revision, + + /// When specific entries are deleted from the interned table, their data is added + /// to this vector rather than being immediately freed. This is because we may` have + /// references to that data floating about that are tied to the lifetime of some + /// `&db` reference. This queue itself is not freed until we have an `&mut db` reference, + /// guaranteeing that there are no more references to it. deleted_entries: SegQueue>, }