pub struct PageAllocator { /* private fields */ }Expand description
In-memory page allocator state.
Implementations§
Source§impl PageAllocator
impl PageAllocator
Sourcepub fn new(high_water_mark: u32) -> Self
pub fn new(high_water_mark: u32) -> Self
Create a new allocator starting from the given high water mark.
Sourcepub fn allocate(&mut self) -> PageId
pub fn allocate(&mut self) -> PageId
Allocate a new page ID. Prefers reusing reclaimed pages; falls back to incrementing the high water mark.
Sourcepub fn free(&mut self, page_id: PageId)
pub fn free(&mut self, page_id: PageId)
Mark a page as freed in the current transaction. The page is NOT immediately reusable — it goes into the pending-free list.
Sourcepub fn high_water_mark(&self) -> u32
pub fn high_water_mark(&self) -> u32
Current high water mark (next page ID that would be allocated from disk).
Sourcepub fn freed_this_txn(&self) -> &[PageId]
pub fn freed_this_txn(&self) -> &[PageId]
Pages freed in the current transaction.
Sourcepub fn add_ready_to_use(&mut self, pages: Vec<PageId>)
pub fn add_ready_to_use(&mut self, pages: Vec<PageId>)
Add pages that are safe to reuse (reclaimed from pending-free chain).
Sourcepub fn commit(&mut self) -> Vec<PageId>
pub fn commit(&mut self) -> Vec<PageId>
Commit: take ownership of freed pages (for writing to pending-free chain). Returns the list of pages freed in this transaction.
Sourcepub fn ready_count(&self) -> usize
pub fn ready_count(&self) -> usize
Number of pages available for immediate reuse.
Sourcepub fn freed_count(&self) -> usize
pub fn freed_count(&self) -> usize
Number of pages freed in the current transaction.
Auto Trait Implementations§
impl Freeze for PageAllocator
impl RefUnwindSafe for PageAllocator
impl Send for PageAllocator
impl Sync for PageAllocator
impl Unpin for PageAllocator
impl UnsafeUnpin for PageAllocator
impl UnwindSafe for PageAllocator
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