Struct swap::file::FilePageStates
source · struct FilePageStates {
first_idx_file_freed: Option<usize>,
states: Vec<FilePageState>,
}
Fields§
§first_idx_file_freed: Option<usize>
Freed pages on the swap file are managed in a free list. first_freed_idx_file
points to
the first page index in the list.
states: Vec<FilePageState>
Implementations§
source§impl FilePageStates
impl FilePageStates
fn new(capacity: usize) -> Self
fn len(&self) -> usize
sourcefn allocate(&mut self, idx_page: usize) -> usize
fn allocate(&mut self, idx_page: usize) -> usize
Allocates a file page on the swap file.
This returns the index of the allocated file page.
This reuses freed file pages first. If the free list is empty, this allocates new pages in the file.
sourcefn find_present_pages_range(
&self,
idx_file: usize,
page_states: &[PageState],
max_pages: usize,
consecutive: bool
) -> Option<(Range<usize>, usize)>
fn find_present_pages_range( &self, idx_file: usize, page_states: &[PageState], max_pages: usize, consecutive: bool ) -> Option<(Range<usize>, usize)>
Find the index range of file pages that are all present.
This returns the pair of range of file page indexes and the index of the corresponding first page.
Returns None
if no pages after idx_file
are present.
§Arguments
idx_file
- The first index to start searching from.page_states
- The page statesmax_pages
- The maximum number of pages to search.consecutive
- If true, the pages must have consecutive idx_page values.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for FilePageStates
impl Send for FilePageStates
impl Sync for FilePageStates
impl Unpin for FilePageStates
impl UnwindSafe for FilePageStates
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