Skip to main content

TileCache

Struct TileCache 

Source
pub struct TileCache { /* private fields */ }
Expand description

A byte-budgeted LRU cache of graph intermediates.

Shared across scheduler threads; all methods take &self.

Implementations§

Source§

impl TileCache

Source

pub const DEFAULT_BUDGET: usize

The default retention budget: 64 MiB.

Source

pub fn new(budget: usize) -> Self

A cache retaining at most budget bytes of tiles.

A budget of zero disables retention entirely: every lookup misses, which is a useful way to test that a pipeline is correct without any caching at all.

Source

pub const fn budget(&self) -> usize

The retention budget in bytes.

Source

pub fn get(&self, key: &TileKey) -> Option<Arc<TileBuf>>

Look up a tile, marking it most-recently-used on a hit.

The returned Arc keeps the tile alive regardless of later eviction.

Source

pub fn insert(&self, key: TileKey, tile: Arc<TileBuf>) -> Arc<TileBuf> ⓘ

Offer a tile to the cache, evicting as needed to stay within budget.

Returns the tile, so a caller can insert and use it in one step. A tile larger than the entire budget is returned without being retained rather than evicting everything to make room for something that cannot fit.

Source

pub fn bytes_used(&self) -> usize

Bytes currently retained.

Source

pub fn len(&self) -> usize

Number of tiles currently retained.

Source

pub fn is_empty(&self) -> bool

Whether the cache retains nothing.

Source

pub fn stats(&self) -> CacheStats

A snapshot of the cache counters.

Source

pub fn clear(&self)

Drop every retained tile, keeping the accumulated statistics.

Trait Implementations§

Source§

impl Debug for TileCache

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for TileCache

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.