pub struct Cache { /* private fields */ }Expand description
LRU cache for kernel matrix rows.
Each of the l data items may have a cached row of length up to l.
The cache tracks how much memory (in Qfloat units) is in use and evicts
LRU entries when the budget is exceeded.
The LRU list is a circular doubly-linked list using array indices.
Index l is the sentinel head node. All operations (insert, remove,
evict) are O(1).
Implementations§
Source§impl Cache
impl Cache
Sourcepub fn new(l: usize, size_bytes: usize) -> Self
pub fn new(l: usize, size_bytes: usize) -> Self
Create a new cache for l data items with size_bytes of memory.
Sourcepub fn get_data(
&mut self,
index: usize,
request_len: usize,
) -> (&mut [Qfloat], usize)
pub fn get_data( &mut self, index: usize, request_len: usize, ) -> (&mut [Qfloat], usize)
Request data for row index of length request_len.
Returns (data, start) where data is the cached row slice and
start is the position from which data needs to be filled.
If start >= request_len, the entire row was already cached.
The caller must fill data[start..request_len] with kernel values.
Sourcepub fn swap_index(&mut self, i: usize, j: usize)
pub fn swap_index(&mut self, i: usize, j: usize)
Swap indices i and j in the cache.
Used by the solver when rearranging the working set.
Auto Trait Implementations§
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin 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
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