From d59413c895e7b49ed2ad01be35871e417a57a43c Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 15 Sep 2018 17:21:47 +0300 Subject: yet another db api --- crates/salsa/src/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'crates/salsa/src') 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::{ }; use parking_lot::Mutex; -type GroundQueryFn = Box (D, OutputFingerprint) + Send + Sync + 'static>; -type QueryFn = Box, &D) -> (D, OutputFingerprint) + Send + Sync + 'static>; +pub type GroundQueryFn = Box (D, OutputFingerprint) + Send + Sync + 'static>; +pub type QueryFn = Box, &D) -> (D, OutputFingerprint) + Send + Sync + 'static>; #[derive(Debug)] pub struct Db { @@ -118,6 +118,9 @@ where self.record_dep(query_id, output_fingerprint); res } + pub fn trace(&self) -> Vec { + ::std::mem::replace(&mut *self.executed.borrow_mut(), Vec::new()) + } fn get_inner( &self, @@ -261,12 +264,15 @@ where query_config: Arc::clone(&self.query_config) } } + pub fn query_ctx(&self) -> QueryCtx { + QueryCtx::new(self) + } pub fn get( &self, query_id: QueryId, params: D, ) -> (D, Vec) { - let ctx = QueryCtx::new(self); + let ctx = self.query_ctx(); let res = ctx.get(query_id, params.into()); let executed = ::std::mem::replace(&mut *ctx.executed.borrow_mut(), Vec::new()); (res, executed) -- cgit v1.2.3