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.
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 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