diff options
author | Aleksey Kladov <[email protected]> | 2018-09-15 15:21:47 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-09-15 22:00:05 +0100 |
commit | d59413c895e7b49ed2ad01be35871e417a57a43c (patch) | |
tree | b0615655a8344c8d079be8c7b1b1e05445c43d7e /crates/salsa/src | |
parent | 0d7b1e442d1449a48e0b73b3db6ea270520ea039 (diff) |
yet another db api
Diffstat (limited to 'crates/salsa/src')
-rw-r--r-- | crates/salsa/src/lib.rs | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/crates/salsa/src/lib.rs b/crates/salsa/src/lib.rs index 75815e8bd..35deed374 100644 --- a/crates/salsa/src/lib.rs +++ b/crates/salsa/src/lib.rs | |||
@@ -8,8 +8,8 @@ use std::{ | |||
8 | }; | 8 | }; |
9 | use parking_lot::Mutex; | 9 | use parking_lot::Mutex; |
10 | 10 | ||
11 | type GroundQueryFn<T, D> = Box<Fn(&T, &D) -> (D, OutputFingerprint) + Send + Sync + 'static>; | 11 | pub type GroundQueryFn<T, D> = Box<Fn(&T, &D) -> (D, OutputFingerprint) + Send + Sync + 'static>; |
12 | type QueryFn<T, D> = Box<Fn(&QueryCtx<T, D>, &D) -> (D, OutputFingerprint) + Send + Sync + 'static>; | 12 | pub type QueryFn<T, D> = Box<Fn(&QueryCtx<T, D>, &D) -> (D, OutputFingerprint) + Send + Sync + 'static>; |
13 | 13 | ||
14 | #[derive(Debug)] | 14 | #[derive(Debug)] |
15 | pub struct Db<T, D> { | 15 | pub struct Db<T, D> { |
@@ -118,6 +118,9 @@ where | |||
118 | self.record_dep(query_id, output_fingerprint); | 118 | self.record_dep(query_id, output_fingerprint); |
119 | res | 119 | res |
120 | } | 120 | } |
121 | pub fn trace(&self) -> Vec<QueryTypeId> { | ||
122 | ::std::mem::replace(&mut *self.executed.borrow_mut(), Vec::new()) | ||
123 | } | ||
121 | 124 | ||
122 | fn get_inner( | 125 | fn get_inner( |
123 | &self, | 126 | &self, |
@@ -261,12 +264,15 @@ where | |||
261 | query_config: Arc::clone(&self.query_config) | 264 | query_config: Arc::clone(&self.query_config) |
262 | } | 265 | } |
263 | } | 266 | } |
267 | pub fn query_ctx(&self) -> QueryCtx<T, D> { | ||
268 | QueryCtx::new(self) | ||
269 | } | ||
264 | pub fn get( | 270 | pub fn get( |
265 | &self, | 271 | &self, |
266 | query_id: QueryId, | 272 | query_id: QueryId, |
267 | params: D, | 273 | params: D, |
268 | ) -> (D, Vec<QueryTypeId>) { | 274 | ) -> (D, Vec<QueryTypeId>) { |
269 | let ctx = QueryCtx::new(self); | 275 | let ctx = self.query_ctx(); |
270 | let res = ctx.get(query_id, params.into()); | 276 | let res = ctx.get(query_id, params.into()); |
271 | let executed = ::std::mem::replace(&mut *ctx.executed.borrow_mut(), Vec::new()); | 277 | let executed = ::std::mem::replace(&mut *ctx.executed.borrow_mut(), Vec::new()); |
272 | (res, executed) | 278 | (res, executed) |