mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-26 14:46:57 +00:00
add a helper method overwrite_placeholder
This commit is contained in:
parent
5849af83ac
commit
5a802ae05c
1 changed files with 20 additions and 18 deletions
|
@ -142,14 +142,7 @@ where
|
|||
let stamped_value = old_memo.stamped_value.clone();
|
||||
|
||||
let mut map_write = self.map.write();
|
||||
let placeholder = map_write.insert(key.clone(), old_value.unwrap());
|
||||
assert!(
|
||||
match placeholder {
|
||||
Some(QueryState::InProgress) => true,
|
||||
_ => false,
|
||||
},
|
||||
"expected in-progress state",
|
||||
);
|
||||
self.overwrite_placeholder(&mut map_write, key, old_value.unwrap());
|
||||
return Ok(stamped_value);
|
||||
}
|
||||
}
|
||||
|
@ -182,26 +175,35 @@ where
|
|||
|
||||
{
|
||||
let mut map_write = self.map.write();
|
||||
|
||||
let old_value = map_write.insert(
|
||||
key.clone(),
|
||||
self.overwrite_placeholder(
|
||||
&mut map_write,
|
||||
key,
|
||||
QueryState::Memoized(Memo {
|
||||
stamped_value: stamped_value.clone(),
|
||||
inputs,
|
||||
verified_at: revision_now,
|
||||
}),
|
||||
);
|
||||
assert!(
|
||||
match old_value {
|
||||
Some(QueryState::InProgress) => true,
|
||||
_ => false,
|
||||
},
|
||||
"expected in-progress state",
|
||||
);
|
||||
}
|
||||
|
||||
Ok(stamped_value)
|
||||
}
|
||||
|
||||
fn overwrite_placeholder(
|
||||
&self,
|
||||
map_write: &mut FxHashMap<Q::Key, QueryState<QC, Q>>,
|
||||
key: &Q::Key,
|
||||
value: QueryState<QC, Q>,
|
||||
) {
|
||||
let old_value = map_write.insert(key.clone(), value);
|
||||
assert!(
|
||||
match old_value {
|
||||
Some(QueryState::InProgress) => true,
|
||||
_ => false,
|
||||
},
|
||||
"expected in-progress state",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
impl<QC, Q> QueryStorageOps<QC, Q> for MemoizedStorage<QC, Q>
|
||||
|
|
Loading…
Reference in a new issue