pub struct S3FifoLayoutCache { /* private fields */ }Expand description
Layout cache backed by S3-FIFO eviction.
Drop-in replacement for LayoutCache that uses the scan-resistant
S3-FIFO eviction policy instead of the HashMap-based LRU. This protects
frequently-accessed layout computations from being evicted by transient
layouts (e.g. popup menus or tooltips that appear once).
Supports the same generation-based invalidation as LayoutCache.
Implementations§
Source§impl S3FifoLayoutCache
impl S3FifoLayoutCache
Sourcepub fn new(max_entries: usize) -> Self
pub fn new(max_entries: usize) -> Self
Create a new S3-FIFO layout cache with the given capacity.
Sourcepub fn get_or_compute<F>(
&mut self,
key: LayoutCacheKey,
compute: F,
) -> Vec<Rect>
pub fn get_or_compute<F>( &mut self, key: LayoutCacheKey, compute: F, ) -> Vec<Rect>
Get cached layout or compute and cache a new one.
Same semantics as LayoutCache::get_or_compute: entries from
a previous generation are treated as misses.
Sourcepub fn invalidate_all(&mut self)
pub fn invalidate_all(&mut self)
Invalidate all entries by bumping the generation (O(1)).
Sourcepub fn stats(&self) -> LayoutCacheStats
pub fn stats(&self) -> LayoutCacheStats
Get current cache statistics.
Sourcepub fn reset_stats(&mut self)
pub fn reset_stats(&mut self)
Reset statistics counters.
Trait Implementations§
Source§impl Debug for S3FifoLayoutCache
impl Debug for S3FifoLayoutCache
Auto Trait Implementations§
impl Freeze for S3FifoLayoutCache
impl RefUnwindSafe for S3FifoLayoutCache
impl Send for S3FifoLayoutCache
impl Sync for S3FifoLayoutCache
impl Unpin for S3FifoLayoutCache
impl UnsafeUnpin for S3FifoLayoutCache
impl UnwindSafe for S3FifoLayoutCache
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more