pub struct ModelRegistry<T> { /* private fields */ }Expand description
Shared resident model registry with weighted LRU eviction.
Implementations§
Source§impl<T> ModelRegistry<T>
impl<T> ModelRegistry<T>
pub fn new(config: RegistryConfig) -> Self
pub fn config(&self) -> &RegistryConfig
pub fn total_weight(&self) -> u64
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn insert(
&self,
key: LoadKey,
value: Arc<T>,
weight: ResidencyWeight,
) -> Result<Arc<RegistryEntry<T>>>
pub fn insert( &self, key: LoadKey, value: Arc<T>, weight: ResidencyWeight, ) -> Result<Arc<RegistryEntry<T>>>
Insert or refresh an entry. Evicts idle entries if needed.
New inserts start with active_refs == 0. Prefer Self::insert_and_pin
when the caller will immediately use the value (JOE-1646).
Sourcepub fn insert_and_pin(
&self,
key: LoadKey,
value: Arc<T>,
weight: ResidencyWeight,
) -> Result<RegistryPin<T>>
pub fn insert_and_pin( &self, key: LoadKey, value: Arc<T>, weight: ResidencyWeight, ) -> Result<RegistryPin<T>>
Insert (or refresh) and return a pin under one lock — no eviction window between publication and active lease (JOE-1646).
pub fn get(&self, key: &LoadKey) -> Option<Arc<RegistryEntry<T>>>
Sourcepub fn pin(&self, key: &LoadKey) -> Option<RegistryPin<T>>
pub fn pin(&self, key: &LoadKey) -> Option<RegistryPin<T>>
Pin for an active operation (prevents eviction).
Prefer Self::get_and_pin when the caller needs the value only while
pinned (atomic lookup+lease).
Sourcepub fn get_and_pin(&self, key: &LoadKey) -> Option<RegistryPin<T>>
pub fn get_and_pin(&self, key: &LoadKey) -> Option<RegistryPin<T>>
Atomic lookup + pin under the registry lock (JOE-1646).
There is no window where the entry can be evicted after the caller has
observed it but before active_refs is incremented.
Sourcepub fn clear_idle(&self) -> (usize, usize)
pub fn clear_idle(&self) -> (usize, usize)
Drop idle entries only (JOE-1646 third-pass).
Entries with active_refs > 0 or pinned stay in the map with their
weight so residency accounting remains truthful and a same-key reload
cannot multiply native sessions while an operation still holds a pin.
Returns (removed, retained_active).
Sourcepub fn clear(&self)
pub fn clear(&self)
Alias for Self::clear_idle — never forcibly drops active leases.
Sourcepub fn try_unload(&self, key: &LoadKey) -> bool
pub fn try_unload(&self, key: &LoadKey) -> bool
Remove a specific key if not active.
pub fn snapshot(&self) -> Vec<RegistrySnapshot>
Auto Trait Implementations§
impl<T> !Freeze for ModelRegistry<T>
impl<T> RefUnwindSafe for ModelRegistry<T>
impl<T> Send for ModelRegistry<T>
impl<T> Sync for ModelRegistry<T>
impl<T> Unpin for ModelRegistry<T>
impl<T> UnsafeUnpin for ModelRegistry<T>
impl<T> UnwindSafe for ModelRegistry<T>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more