pub struct SpecializationCache<V> { /* private fields */ }Expand description
Small exact-key LRU for compiled shape specializations.
This portable cache is deliberately synchronization-free. A concurrent provider should put a lock or single-flight compilation state around it at its existing program/queue owner boundary.
Implementations§
Source§impl<V> SpecializationCache<V>
impl<V> SpecializationCache<V>
pub fn new(capacity: NonZeroUsize) -> Self
pub const fn capacity(&self) -> usize
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get(&mut self, key: &SpecializationKey) -> Option<&V>
pub fn get_mut(&mut self, key: &SpecializationKey) -> Option<&mut V>
Sourcepub fn insert(
&mut self,
key: SpecializationKey,
value: V,
) -> Result<Option<V>, CacheInsertError<V>>
pub fn insert( &mut self, key: SpecializationKey, value: V, ) -> Result<Option<V>, CacheInsertError<V>>
Insert or replace a specialization, returning the replaced or evicted compiled value.
Trait Implementations§
Auto Trait Implementations§
impl<V> Freeze for SpecializationCache<V>
impl<V> RefUnwindSafe for SpecializationCache<V>where
V: RefUnwindSafe,
impl<V> Send for SpecializationCache<V>where
V: Send,
impl<V> Sync for SpecializationCache<V>where
V: Sync,
impl<V> Unpin for SpecializationCache<V>where
V: Unpin,
impl<V> UnsafeUnpin for SpecializationCache<V>
impl<V> UnwindSafe for SpecializationCache<V>where
V: UnwindSafe,
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