Struct swap::present_list::PresentList
source · pub struct PresentList {
list: Vec<bool>,
min_possible_idx: usize,
}
Expand description
PresentList is a utility for tracking whether or not pages in an address space are present.
TODO(b/262379173): Use bit vector to represent the list instead of boolean vector.
Fields§
§list: Vec<bool>
§min_possible_idx: usize
Cursor used when iterating over pages present. All pages with indices less than the cursor are known to be empty.
Implementations§
source§impl PresentList
impl PresentList
sourcepub fn mark_as_present(&mut self, idx_range: Range<usize>) -> bool
pub fn mark_as_present(&mut self, idx_range: Range<usize>) -> bool
Marks the range of indices as present.
§Arguments
idx_range
- the indices of consecutive pages to be marked as present.
sourcepub fn clear_range(&mut self, idx_range: Range<usize>) -> bool
pub fn clear_range(&mut self, idx_range: Range<usize>) -> bool
Clears the states of the pages.
§Arguments
idx_range
- the indices of consecutive pages to be cleared.
fn update(&mut self, idx_range: Range<usize>, value: bool) -> bool
sourcepub fn first_data_range(&mut self, max_pages: usize) -> Option<Range<usize>>
pub fn first_data_range(&mut self, max_pages: usize) -> Option<Range<usize>>
Returns the first range of indices of consecutive pages present in the list.
§Arguments
max_pages
- the max size of the returned chunk even if the chunk of consecutive present pages is longer than this.
sourcepub fn find_data_range(
&self,
head_idx: usize,
max_pages: usize
) -> Option<Range<usize>>
pub fn find_data_range( &self, head_idx: usize, max_pages: usize ) -> Option<Range<usize>>
Returns the first range of indices of consecutive pages present in the list after
head_idx
.
§Arguments
head_idx
- The index to start seeking data with.max_pages
- The max size of the returned chunk even if the chunk of consecutive present pages is longer than this.
sourcepub fn all_present_pages(&self) -> usize
pub fn all_present_pages(&self) -> usize
Returns the count of present pages in the list.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for PresentList
impl Send for PresentList
impl Sync for PresentList
impl Unpin for PresentList
impl UnwindSafe for PresentList
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