pub struct ShapeCache { /* private fields */ }Expand description
Thread-safe bounded LRU cache for ShapedRuns.
Wraps lru::LruCache in an RwLock. Cache misses trigger a write
lock, cache hits also require a write lock because LRU must update the
recency order on every get.
Implementations§
Source§impl ShapeCache
impl ShapeCache
Sourcepub fn new(capacity: usize) -> Self
pub fn new(capacity: usize) -> Self
Creates a new cache with the given capacity.
If capacity is 0, falls back to a minimum capacity of 1 so the cache
is always usable without panicking.
Sourcepub fn get(&self, key: &ShapeKey) -> Option<Arc<ShapedRun>>
pub fn get(&self, key: &ShapeKey) -> Option<Arc<ShapedRun>>
Look up a cached ShapedRun by key.
Returns Some(Arc<ShapedRun>) on a cache hit and updates the LRU order.
Returns None on a miss or if the lock is poisoned.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for ShapeCache
impl RefUnwindSafe for ShapeCache
impl Send for ShapeCache
impl Sync for ShapeCache
impl Unpin for ShapeCache
impl UnsafeUnpin for ShapeCache
impl UnwindSafe for ShapeCache
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