mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-29 15:49:13 +00:00
move CycleError to the plumbing module
This commit is contained in:
parent
79f8acc3aa
commit
0298163211
3 changed files with 9 additions and 13 deletions
|
@ -353,16 +353,11 @@ where
|
|||
ProbeState::UpToDate(if result.cycle.is_empty() {
|
||||
Ok(result.value)
|
||||
} else {
|
||||
let err = CycleError {
|
||||
cycle: result.cycle,
|
||||
changed_at: result.value.changed_at,
|
||||
durability: result.value.durability,
|
||||
};
|
||||
runtime.mark_cycle_participants(&err);
|
||||
runtime.mark_cycle_participants(&result.cycle);
|
||||
Ok(StampedValue {
|
||||
value: Q::cycle_fallback(db, &err.cycle, &self.key),
|
||||
durability: err.durability,
|
||||
changed_at: err.changed_at,
|
||||
value: Q::cycle_fallback(db, &result.cycle, &self.key),
|
||||
durability: result.value.durability,
|
||||
changed_at: result.value.changed_at,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ pub trait QueryFunction: Query {
|
|||
|
||||
/// Cycle recovery strategy: Is this query capable of recovering from
|
||||
/// a cycle that results from executing the function? If so, how?
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum CycleRecoveryStrategy {
|
||||
/// Cannot recover from cycles: panic.
|
||||
///
|
||||
|
@ -244,6 +244,7 @@ pub struct CycleError<K> {
|
|||
pub(crate) cycle: Vec<K>,
|
||||
pub(crate) changed_at: Revision,
|
||||
pub(crate) durability: Durability,
|
||||
// pub(crate) recovery_strategy: CycleRecoveryStrategy,
|
||||
}
|
||||
|
||||
impl CycleError<DatabaseKeyIndex> {
|
||||
|
|
|
@ -397,19 +397,19 @@ impl Runtime {
|
|||
}
|
||||
}
|
||||
|
||||
pub(crate) fn mark_cycle_participants(&self, err: &CycleError<DatabaseKeyIndex>) {
|
||||
pub(crate) fn mark_cycle_participants(&self, participants: &[DatabaseKeyIndex]) {
|
||||
for active_query in self
|
||||
.local_state
|
||||
.borrow_query_stack_mut()
|
||||
.iter_mut()
|
||||
.rev()
|
||||
.take_while(|active_query| {
|
||||
err.cycle
|
||||
participants
|
||||
.iter()
|
||||
.any(|e| *e == active_query.database_key_index)
|
||||
})
|
||||
{
|
||||
active_query.cycle = err.cycle.clone();
|
||||
active_query.cycle = participants.to_owned();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue