Struct AtomicBitmap

Source
pub struct AtomicBitmap { /* private fields */ }
Available on crate feature backend-bitmap only.
Expand description

AtomicBitmap implements a simple bit map on the page level with test and set operations. It is page-size aware, so it converts addresses to page numbers before setting or clearing the bits.

Implementations§

Source§

impl AtomicBitmap

Source

pub fn new(byte_size: usize, page_size: NonZeroUsize) -> Self

Create a new bitmap of byte_size, with one bit per page. This is effectively rounded up, and we get a new vector of the next multiple of 64 bigger than bit_size.

Source

pub fn enlarge(&mut self, additional_size: usize)

Enlarge this bitmap with enough bits to track additional_size additional bytes at page granularity. New bits are initialized to zero.

Source

pub fn is_bit_set(&self, index: usize) -> bool

Is bit n set? Bits outside the range of the bitmap are always unset.

Source

pub fn is_addr_set(&self, addr: usize) -> bool

Is the bit corresponding to address addr set?

Source

pub fn set_addr_range(&self, start_addr: usize, len: usize)

Set a range of len bytes starting at start_addr. The first bit set in the bitmap is for the page corresponding to start_addr, and the last bit that we set corresponds to address start_addr + len - 1.

Source

pub fn reset_addr_range(&self, start_addr: usize, len: usize)

Reset a range of len bytes starting at start_addr. The first bit set in the bitmap is for the page corresponding to start_addr, and the last bit that we set corresponds to address start_addr + len - 1.

Source

pub fn set_bit(&self, index: usize)

Set bit to corresponding index

Source

pub fn reset_bit(&self, index: usize)

Reset bit to corresponding index

Source

pub fn len(&self) -> usize

Get the length of the bitmap in bits (i.e. in how many pages it can represent).

Source

pub fn byte_size(&self) -> usize

Get the size in bytes i.e how many bytes the bitmap can represent, one bit per page.

Source

pub fn get_and_reset(&self) -> Vec<u64>

Atomically get and reset the dirty page bitmap.

Source

pub fn reset(&self)

Reset all bitmap bits to 0.

Trait Implementations§

Source§

impl Bitmap for AtomicBitmap

Source§

fn mark_dirty(&self, offset: usize, len: usize)

Mark the memory range specified by the given offset and len as dirtied.
Source§

fn dirty_at(&self, offset: usize) -> bool

Check whether the specified offset is marked as dirty.
Source§

fn slice_at(&self, offset: usize) -> <Self as WithBitmapSlice<'_>>::S

Return a <Self as WithBitmapSlice>::S slice of the current bitmap, starting at the specified offset.
Source§

impl Clone for AtomicBitmap

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AtomicBitmap

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for AtomicBitmap

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl NewBitmap for AtomicBitmap

Available on crate feature backend-mmap only.
Source§

fn with_len(len: usize) -> Self

Create a new object based on the specified length in bytes.
Source§

impl<'a> WithBitmapSlice<'a> for AtomicBitmap

Source§

type S = BaseSlice<&'a AtomicBitmap>

Type of the bitmap slice.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.