mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-23 05:07:27 +00:00
introduce a callback into execute_query_implementation
This commit is contained in:
parent
30236cc110
commit
1e6bfc7fdd
3 changed files with 15 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue