pub struct Cache {
pub cache_size: usize,
pub cache_state: Arc<RwLock<LruCache<GenesHash, FitnessValue, BuildHasherDefault<NoHashHasher<u64>>>>>,
pub cache_hit_counter: Arc<RwLock<usize>>,
pub cache_miss_counter: Arc<RwLock<usize>>,
}
Fields§
§cache_size: usize
§cache_state: Arc<RwLock<LruCache<GenesHash, FitnessValue, BuildHasherDefault<NoHashHasher<u64>>>>>
§cache_hit_counter: Arc<RwLock<usize>>
§cache_miss_counter: Arc<RwLock<usize>>
Implementations§
Source§impl Cache
impl Cache
pub fn try_new(cache_size: usize) -> Result<Self, &'static str>
pub fn read(&self, genes_hash: GenesHash) -> Option<FitnessValue>
pub fn write(&self, genes_hash: GenesHash, value: FitnessValue)
Sourcepub fn hit_miss_stats(&self) -> (usize, usize, f32)
pub fn hit_miss_stats(&self) -> (usize, usize, f32)
hit_miss_stats() -> (hits, misses, ratio)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnwindSafe for Cache
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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