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

source

pub fn new(num_of_pages: usize) -> Self

Allocates the list of state.

§Arguments
  • num_of_pages - the number of pages in the region.
source

pub fn get(&self, idx: usize) -> Option<&bool>

Returns whether the page is present or not

§Arguments
  • idx - the index in the list.
source

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

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

fn update(&mut self, idx_range: Range<usize>, value: bool) -> bool

source

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

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

pub fn all_present_pages(&self) -> usize

Returns the count of present pages in the list.

Trait Implementations§

source§

impl Debug for PresentList

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.