pub trait AllocPage: LoadPage {
// Required methods
unsafe fn alloc_page(&mut self) -> Result<MutPage, Self::Error>;
unsafe fn alloc_contiguous(
&mut self,
length: u64,
) -> Result<MutPage, Self::Error>;
fn incr_rc(&mut self, off: u64) -> Result<usize, Self::Error>;
unsafe fn decr_rc(&mut self, off: u64) -> Result<usize, Self::Error>;
unsafe fn decr_rc_owned(&mut self, off: u64) -> Result<usize, Self::Error>;
// Provided method
unsafe fn alloc_page_no_dirty(&mut self) -> Result<MutPage, Self::Error> { ... }
}
Expand description
Trait for allocating and freeing pages.
Required Methods§
sourceunsafe fn alloc_page(&mut self) -> Result<MutPage, Self::Error>
unsafe fn alloc_page(&mut self) -> Result<MutPage, Self::Error>
Allocate a new page.
sourceunsafe fn alloc_contiguous(
&mut self,
length: u64,
) -> Result<MutPage, Self::Error>
unsafe fn alloc_contiguous( &mut self, length: u64, ) -> Result<MutPage, Self::Error>
Allocate many contiguous pages, return the first one. The dirty bit is not needed.
sourcefn incr_rc(&mut self, off: u64) -> Result<usize, Self::Error>
fn incr_rc(&mut self, off: u64) -> Result<usize, Self::Error>
Increment the page’s reference count.
sourceunsafe fn decr_rc(&mut self, off: u64) -> Result<usize, Self::Error>
unsafe fn decr_rc(&mut self, off: u64) -> Result<usize, Self::Error>
Decrement the page’s reference count, assuming the page was first allocated by another transaction. If the RC reaches 0, free the page. Must return the new RC (0 if freed).
sourceunsafe fn decr_rc_owned(&mut self, off: u64) -> Result<usize, Self::Error>
unsafe fn decr_rc_owned(&mut self, off: u64) -> Result<usize, Self::Error>
Same as Self::decr_rc
, but for pages allocated by the current
transaction. This is an important distinction, as pages
allocated by the current transaction can be reused immediately
after being freed.
Provided Methods§
sourceunsafe fn alloc_page_no_dirty(&mut self) -> Result<MutPage, Self::Error>
unsafe fn alloc_page_no_dirty(&mut self) -> Result<MutPage, Self::Error>
Allocate a new page, in a context where we cannot use the “dirty bit” trick directly on the page.