mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-24 13:48:03 +00:00
commit
2084b99ba4
6 changed files with 30 additions and 1 deletions
|
@ -205,6 +205,10 @@ where
|
||||||
slot.sweep(revision_now, strategy);
|
slot.sweep(revision_now, strategy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fn purge(&self) {
|
||||||
|
self.lru_list.purge();
|
||||||
|
*self.slot_map.write() = Default::default();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Q, MP> LruQueryStorageOps for DerivedStorage<Q, MP>
|
impl<Q, MP> LruQueryStorageOps for DerivedStorage<Q, MP>
|
||||||
|
|
|
@ -162,6 +162,9 @@ where
|
||||||
Q: Query,
|
Q: Query,
|
||||||
{
|
{
|
||||||
fn sweep(&self, _runtime: &Runtime, _strategy: SweepStrategy) {}
|
fn sweep(&self, _runtime: &Runtime, _strategy: SweepStrategy) {}
|
||||||
|
fn purge(&self) {
|
||||||
|
*self.slots.write() = Default::default();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Q> InputQueryStorageOps<Q> for InputStorage<Q>
|
impl<Q> InputQueryStorageOps<Q> for InputStorage<Q>
|
||||||
|
|
|
@ -407,6 +407,9 @@ where
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
fn purge(&self) {
|
||||||
|
*self.tables.write() = Default::default();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Q, IQ> QueryStorageOps<Q> for LookupInternedStorage<Q, IQ>
|
impl<Q, IQ> QueryStorageOps<Q> for LookupInternedStorage<Q, IQ>
|
||||||
|
@ -505,6 +508,7 @@ where
|
||||||
>,
|
>,
|
||||||
{
|
{
|
||||||
fn sweep(&self, _: &Runtime, _strategy: SweepStrategy) {}
|
fn sweep(&self, _: &Runtime, _strategy: SweepStrategy) {}
|
||||||
|
fn purge(&self) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<K> Slot<K> {
|
impl<K> Slot<K> {
|
||||||
|
|
14
src/lib.rs
14
src/lib.rs
|
@ -203,6 +203,7 @@ impl Default for DiscardWhat {
|
||||||
pub struct SweepStrategy {
|
pub struct SweepStrategy {
|
||||||
discard_if: DiscardIf,
|
discard_if: DiscardIf,
|
||||||
discard_what: DiscardWhat,
|
discard_what: DiscardWhat,
|
||||||
|
shrink_to_fit: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SweepStrategy {
|
impl SweepStrategy {
|
||||||
|
@ -491,7 +492,18 @@ where
|
||||||
{
|
{
|
||||||
self.storage.sweep(self.db.salsa_runtime(), strategy);
|
self.storage.sweep(self.db.salsa_runtime(), strategy);
|
||||||
}
|
}
|
||||||
}
|
/// Completely clears the storage for this query.
|
||||||
|
///
|
||||||
|
/// This method breaks internal invariants of salsa, so any further queries
|
||||||
|
/// might return nonsense results. It is useful only in very specific
|
||||||
|
/// circumstances -- for example, when one wants to observe which values
|
||||||
|
/// dropped together with the table
|
||||||
|
pub fn purge(&self)
|
||||||
|
where
|
||||||
|
Q::Storage: plumbing::QueryStorageMassOps,
|
||||||
|
{
|
||||||
|
self.storage.purge();
|
||||||
|
}}
|
||||||
|
|
||||||
/// Return value from [the `query_mut` method] on `Database`.
|
/// Return value from [the `query_mut` method] on `Database`.
|
||||||
/// Gives access to the `set` method, notably, that is used to
|
/// Gives access to the `set` method, notably, that is used to
|
||||||
|
|
|
@ -127,6 +127,11 @@ where
|
||||||
|
|
||||||
self.data.lock().record_use(node)
|
self.data.lock().record_use(node)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn purge(&self) {
|
||||||
|
self.green_zone.store(0, Ordering::SeqCst);
|
||||||
|
*self.data.lock() = LruData::with_seed(LRU_SEED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<Node> LruData<Node>
|
impl<Node> LruData<Node>
|
||||||
|
|
|
@ -66,6 +66,7 @@ pub trait DatabaseOps {
|
||||||
pub trait QueryStorageMassOps {
|
pub trait QueryStorageMassOps {
|
||||||
/// Discards memoized values that are not up to date with the current revision.
|
/// Discards memoized values that are not up to date with the current revision.
|
||||||
fn sweep(&self, runtime: &Runtime, strategy: SweepStrategy);
|
fn sweep(&self, runtime: &Runtime, strategy: SweepStrategy);
|
||||||
|
fn purge(&self);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait DatabaseKey: Clone + Debug + Eq + Hash {}
|
pub trait DatabaseKey: Clone + Debug + Eq + Hash {}
|
||||||
|
|
Loading…
Reference in a new issue