mirror of
https://github.com/salsa-rs/salsa.git
synced 2024-12-27 06:27:45 +00:00
add a (unused) report_query_read
to runtime to track deps
This commit is contained in:
parent
5ed8cafe04
commit
738e285c5c
1 changed files with 25 additions and 1 deletions
|
@ -82,6 +82,23 @@ where
|
|||
value
|
||||
}
|
||||
|
||||
/// Reports that the currently active query read the result from
|
||||
/// another query.
|
||||
///
|
||||
/// # Parameters
|
||||
///
|
||||
/// - `descriptor`: the query whose result was read
|
||||
/// - `changed_revision`: the last revision in which the result of that
|
||||
/// query had changed
|
||||
crate fn report_query_read(&self, descriptor: QC::QueryDescriptor, changed_revision: Revision) {
|
||||
self.local_state
|
||||
.borrow_mut()
|
||||
.query_stack
|
||||
.last_mut()
|
||||
.unwrap()
|
||||
.add_read(descriptor, changed_revision);
|
||||
}
|
||||
|
||||
/// Obviously, this should be user configurable at some point.
|
||||
crate fn report_unexpected_cycle(&self, descriptor: QC::QueryDescriptor) -> ! {
|
||||
let local_state = self.local_state.borrow();
|
||||
|
@ -107,7 +124,8 @@ struct SharedState<QC: QueryContext> {
|
|||
revision: AtomicU64,
|
||||
}
|
||||
|
||||
/// State that will be specific to a single execution threads (when we support multiple threads)
|
||||
/// State that will be specific to a single execution threads (when we
|
||||
/// support multiple threads)
|
||||
struct LocalState<QC: QueryContext> {
|
||||
query_stack: Vec<ActiveQuery<QC>>,
|
||||
}
|
||||
|
@ -133,6 +151,12 @@ impl<QC: QueryContext> ActiveQuery<QC> {
|
|||
subqueries: FxIndexSet::default(),
|
||||
}
|
||||
}
|
||||
|
||||
fn add_read(&mut self, subquery: QC::QueryDescriptor, changed_revision: Revision) {
|
||||
if self.subqueries.insert(subquery) {
|
||||
self.max_revision_read = self.max_revision_read.max(changed_revision);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
|
||||
|
|
Loading…
Reference in a new issue