From 72a5b50368f0ab55a6ad204e14b728c3ff3d4678 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sat, 29 Sep 2018 06:44:08 -0400 Subject: [PATCH] update comments and remove storage --- examples/hello_world/implementation.rs | 22 ++++++++++---------- examples/storage_varieties/implementation.rs | 4 ---- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/examples/hello_world/implementation.rs b/examples/hello_world/implementation.rs index 6d40a46a..0f9124b3 100644 --- a/examples/hello_world/implementation.rs +++ b/examples/hello_world/implementation.rs @@ -7,24 +7,24 @@ use salsa::query_context_storage; /// interacts with it through traits and never knows its real name). /// /// Query contexts can contain whatever you want them to, but salsa -/// requires two things: -/// -/// - a salsa runtime (the `runtime` field, here) -/// - query storage (declared using the `query_context_storage` macro below) +/// requires you to add a `salsa::runtime::Runtime` member. Note +/// though: you should be very careful if adding shared, mutable state +/// to your context (e.g., a shared counter or some such thing). If +/// mutations to that shared state affect the results of your queries, +/// that's going to mess up the incremental results. #[derive(Default)] pub struct QueryContextImpl { runtime: salsa::runtime::Runtime, - storage: QueryContextImplStorage, + + /// An interner is an example of shared mutable state that would + /// be ok: although the interner allocates internally when you + /// intern something new, this never affects any previously + /// interned values, so it's not going to affect query results. interner: Interner, } -/// This impl tells salsa where to find the runtime and storage in -/// your query context. +/// This impl tells salsa where to find the salsa runtime. impl salsa::QueryContext for QueryContextImpl { - fn salsa_storage(&self) -> &QueryContextImplStorage { - &self.storage - } - fn salsa_runtime(&self) -> &salsa::runtime::Runtime { &self.runtime } diff --git a/examples/storage_varieties/implementation.rs b/examples/storage_varieties/implementation.rs index db819536..aa54b1fc 100644 --- a/examples/storage_varieties/implementation.rs +++ b/examples/storage_varieties/implementation.rs @@ -25,10 +25,6 @@ impl queries::CounterContext for QueryContextImpl { } impl salsa::QueryContext for QueryContextImpl { - fn extra(&self) -> u32 { - 0 - } - fn salsa_runtime(&self) -> &salsa::runtime::Runtime { &self.runtime }