pub struct RuleLevelCache { /* private fields */ }Expand description
Thread-safe LRU cache keyed by (fsm_hash, new_state_id, state_cnt, edge_cnt), sharded by
(fsm_hash, new_state_id). Eviction is performed per shard, each owning an equal share of the
memory budget.
Implementations§
Source§impl RuleLevelCache
impl RuleLevelCache
Sourcepub fn new(max_cache_memory_size: usize) -> Self
pub fn new(max_cache_memory_size: usize) -> Self
Creates a cache with the given memory budget (UNLIMITED_SIZE = unlimited).
Sourcepub fn get_cache(
&self,
fsm_hash: u64,
fsm_new_node_id: i32,
state_cnt: i32,
edge_cnt: i32,
) -> Option<AdaptiveTokenMask>
pub fn get_cache( &self, fsm_hash: u64, fsm_new_node_id: i32, state_cnt: i32, edge_cnt: i32, ) -> Option<AdaptiveTokenMask>
Returns a cached adaptive token mask, if present.
Sourcepub fn add_cache(
&self,
fsm_hash: u64,
fsm_new_node_id: i32,
state_cnt: i32,
edge_cnt: i32,
token_mask: AdaptiveTokenMask,
) -> bool
pub fn add_cache( &self, fsm_hash: u64, fsm_new_node_id: i32, state_cnt: i32, edge_cnt: i32, token_mask: AdaptiveTokenMask, ) -> bool
Inserts an adaptive token mask into the cache.
Sourcepub fn clear_cache(&self)
pub fn clear_cache(&self)
Clears all cached entries.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for RuleLevelCache
impl RefUnwindSafe for RuleLevelCache
impl Send for RuleLevelCache
impl Sync for RuleLevelCache
impl Unpin for RuleLevelCache
impl UnsafeUnpin for RuleLevelCache
impl UnwindSafe for RuleLevelCache
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
Converts
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> ⓘ
Converts
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