introduce a callback into execute_query_implementation

This commit is contained in:
Niko Matsakis 2018-10-09 10:26:33 -04:00
parent 30236cc110
commit 1e6bfc7fdd
3 changed files with 15 additions and 12 deletions

View file

@ -202,9 +202,12 @@ where
// Query was not previously executed, or value is potentially
// stale, or value is absent. Let's execute!
let (mut stamped_value, inputs) = db
.salsa_runtime()
.execute_query_implementation::<Q>(db, descriptor, key);
let (mut stamped_value, inputs) =
db.salsa_runtime()
.execute_query_implementation(db, descriptor, || {
debug!("{:?}({:?}): executing query", Q::default(), key);
Q::execute(db, key.clone())
});
// We assume that query is side-effect free -- that is, does
// not mutate the "inputs" to the query system. Sanity check

View file

@ -88,16 +88,13 @@ where
result
}
crate fn execute_query_implementation<Q>(
crate fn execute_query_implementation<V>(
&self,
db: &DB,
descriptor: &DB::QueryDescriptor,
key: &Q::Key,
) -> (StampedValue<Q::Value>, QueryDescriptorSet<DB>)
where
Q: QueryFunction<DB>,
{
debug!("{:?}({:?}): executing query", Q::default(), key);
execute: impl FnOnce() -> V,
) -> (StampedValue<V>, QueryDescriptorSet<DB>) {
debug!("{:?}: execute_query_implementation invoked", descriptor);
// Push the active query onto the stack.
let push_len = {
@ -109,7 +106,7 @@ where
};
// Execute user's code, accumulating inputs etc.
let value = Q::execute(db, key.clone());
let value = execute();
// Extract accumulated inputs.
let ActiveQuery {

View file

@ -64,7 +64,10 @@ where
_inputs,
) = db
.salsa_runtime()
.execute_query_implementation::<Q>(db, descriptor, key);
.execute_query_implementation(db, descriptor, || {
debug!("{:?}({:?}): executing query", Q::default(), key);
Q::execute(db, key.clone())
});
let was_in_progress = self.in_progress.lock().remove(key);
assert!(was_in_progress);