[−][src]Trait rustc_query_system::query::caches::QueryCache

pub trait QueryCache: QueryStorage {
    type Key: Hash + Eq + Clone + Debug;
    type Sharded: Default;
    pub fn lookup<D, Q, R, OnHit, OnMiss>(
        &self,
        state: &QueryState<D, Q, Self>,
        key: Self::Key,
        on_hit: OnHit,
        on_miss: OnMiss
    ) -> R
    where
        OnHit: FnOnce(&Self::Stored, DepNodeIndex) -> R,
        OnMiss: FnOnce(Self::Key, QueryLookup<'_, D, Q, Self::Key, Self::Sharded>) -> R
;
pub fn complete(
        &self,
        lock_sharded_storage: &mut Self::Sharded,
        key: Self::Key,
        value: Self::Value,
        index: DepNodeIndex
    ) -> Self::Stored;
pub fn iter<R, L>(
        &self,
        shards: &Sharded<L>,
        get_shard: impl Fn(&mut L) -> &mut Self::Sharded,
        f: impl for<'a> FnOnce(Box<dyn Iterator<Item = (&'a Self::Key, &'a Self::Value, DepNodeIndex)> + 'a>) -> R
    ) -> R; }

Associated Types

type Key: Hash + Eq + Clone + Debug[src]

type Sharded: Default[src]

Loading content...

Required methods

pub fn lookup<D, Q, R, OnHit, OnMiss>(
    &self,
    state: &QueryState<D, Q, Self>,
    key: Self::Key,
    on_hit: OnHit,
    on_miss: OnMiss
) -> R where
    OnHit: FnOnce(&Self::Stored, DepNodeIndex) -> R,
    OnMiss: FnOnce(Self::Key, QueryLookup<'_, D, Q, Self::Key, Self::Sharded>) -> R, 
[src]

Checks if the query is already computed and in the cache. It returns the shard index and a lock guard to the shard, which will be used if the query is not in the cache and we need to compute it.

pub fn complete(
    &self,
    lock_sharded_storage: &mut Self::Sharded,
    key: Self::Key,
    value: Self::Value,
    index: DepNodeIndex
) -> Self::Stored
[src]

pub fn iter<R, L>(
    &self,
    shards: &Sharded<L>,
    get_shard: impl Fn(&mut L) -> &mut Self::Sharded,
    f: impl for<'a> FnOnce(Box<dyn Iterator<Item = (&'a Self::Key, &'a Self::Value, DepNodeIndex)> + 'a>) -> R
) -> R
[src]

Loading content...

Implementors

impl<'tcx, K, V: 'tcx> QueryCache for ArenaCache<'tcx, K, V> where
    K: Eq + Hash + Clone + Debug, 
[src]

type Key = K

type Sharded = FxHashMap<K, &'tcx (V, DepNodeIndex)>

impl<K, V> QueryCache for DefaultCache<K, V> where
    K: Eq + Hash + Clone + Debug,
    V: Clone, 
[src]

type Key = K

type Sharded = FxHashMap<K, (V, DepNodeIndex)>

Loading content...