pub struct GlobalSampleCache { /* private fields */ }Expand description
Thread-safe, global cache for sampled values.
Implementations§
Source§impl GlobalSampleCache
impl GlobalSampleCache
Sourcepub fn insert(&self, key: (usize, u64), value: SampledValue)
pub fn insert(&self, key: (usize, u64), value: SampledValue)
Inserts a value into the cache.
Sourcepub fn get_or_compute<F>(
&self,
key: (usize, u64),
compute_fn: F,
) -> Result<SampledValue, UncertainError>
pub fn get_or_compute<F>( &self, key: (usize, u64), compute_fn: F, ) -> Result<SampledValue, UncertainError>
Gets a value from the cache, or computes it if not present, then caches and returns it. This implementation includes a double-check to prevent redundant computation in concurrent scenarios.
Trait Implementations§
Source§impl Debug for GlobalSampleCache
impl Debug for GlobalSampleCache
Auto Trait Implementations§
impl !Freeze for GlobalSampleCache
impl RefUnwindSafe for GlobalSampleCache
impl Send for GlobalSampleCache
impl Sync for GlobalSampleCache
impl Unpin for GlobalSampleCache
impl UnwindSafe for GlobalSampleCache
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