pub struct AtomicBitmap { /* private fields */ }
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
impl AtomicBitmap
Sourcepub fn new(byte_size: usize, page_size: NonZeroUsize) -> Self
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
.
Sourcepub fn enlarge(&mut self, additional_size: usize)
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.
Sourcepub fn is_bit_set(&self, index: usize) -> bool
pub fn is_bit_set(&self, index: usize) -> bool
Is bit n
set? Bits outside the range of the bitmap are always unset.
Sourcepub fn is_addr_set(&self, addr: usize) -> bool
pub fn is_addr_set(&self, addr: usize) -> bool
Is the bit corresponding to address addr
set?
Sourcepub fn set_addr_range(&self, start_addr: usize, len: usize)
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
.
Sourcepub fn reset_addr_range(&self, start_addr: usize, len: usize)
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
.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the length of the bitmap in bits (i.e. in how many pages it can represent).
Sourcepub fn byte_size(&self) -> usize
pub fn byte_size(&self) -> usize
Get the size in bytes i.e how many bytes the bitmap can represent, one bit per page.
Sourcepub fn get_and_reset(&self) -> Vec<u64>
pub fn get_and_reset(&self) -> Vec<u64>
Atomically get and reset the dirty page bitmap.
Trait Implementations§
Source§impl Bitmap for AtomicBitmap
impl Bitmap for AtomicBitmap
Source§impl Clone for AtomicBitmap
impl Clone for AtomicBitmap
Source§impl Debug for AtomicBitmap
impl Debug for AtomicBitmap
Source§impl Default for AtomicBitmap
impl Default for AtomicBitmap
Source§impl NewBitmap for AtomicBitmap
Available on crate feature backend-mmap
only.
impl NewBitmap for AtomicBitmap
backend-mmap
only.