struct Cache<T> {
map: HashMap<i64, (u64, usize, Arc<T>)>,
bytes: usize,
tick: u64,
protect: (i64, i64),
}Expand description
Byte-budgeted LRU keyed by frame index on the project fps grid. The whole cache is cleared on any change that could affect the picture, so entries never go stale.
Fields§
§map: HashMap<i64, (u64, usize, Arc<T>)>frame index -> (last-use tick, payload bytes, payload)
bytes: usize§tick: u64§protect: (i64, i64)Inclusive index range evicted last (playhead trail + prefetch horizon).
Implementations§
Source§impl<T> Cache<T>
impl<T> Cache<T>
fn new() -> Self
Sourcefn set_protect(&mut self, lo: i64, hi: i64)
fn set_protect(&mut self, lo: i64, hi: i64)
Frames in [lo, hi] are evicted only when nothing else is left to evict.
fn get(&mut self, idx: i64) -> Option<Arc<T>>
fn contains(&self, idx: i64) -> bool
Sourcefn insert(&mut self, idx: i64, bytes: usize, v: Arc<T>) -> Vec<Arc<T>>
fn insert(&mut self, idx: i64, bytes: usize, v: Arc<T>) -> Vec<Arc<T>>
Insert and evict LRU entries down to the budget; evicted payloads come back for buffer recycling.
Auto Trait Implementations§
impl<T> Freeze for Cache<T>
impl<T> RefUnwindSafe for Cache<T>where
T: RefUnwindSafe,
impl<T> Send for Cache<T>
impl<T> Sync for Cache<T>
impl<T> Unpin for Cache<T>
impl<T> UnwindSafe for Cache<T>where
T: RefUnwindSafe,
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<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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