Skip to content

Commit ff882be

Browse files
russell-islamroypat
authored andcommitted
atomic_bitmap: keep the byte_size in the AtomicBitmap
Keeping the byte_size in the struct gives freedom to the caller to use it for any processing at their end.This field can be used by the caller in case of enlarging the bitmap. Signed-off-by: Muminul Islam <[email protected]>
1 parent f56ca47 commit ff882be

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/bitmap/backend/atomic_bitmap.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use crate::mmap::NewBitmap;
1818
pub struct AtomicBitmap {
1919
map: Vec<AtomicU64>,
2020
size: usize,
21+
byte_size: usize,
2122
page_size: NonZeroUsize,
2223
}
2324

@@ -33,6 +34,7 @@ impl AtomicBitmap {
3334
AtomicBitmap {
3435
map,
3536
size: num_pages,
37+
byte_size,
3638
page_size,
3739
}
3840
}
@@ -117,6 +119,11 @@ impl AtomicBitmap {
117119
self.size
118120
}
119121

122+
/// Get the size in bytes i.e how many bytes the bitmap can represent, one bit per page.
123+
pub fn byte_size(&self) -> usize {
124+
self.byte_size
125+
}
126+
120127
/// Atomically get and reset the dirty page bitmap.
121128
pub fn get_and_reset(&self) -> Vec<u64> {
122129
self.map
@@ -144,6 +151,7 @@ impl Clone for AtomicBitmap {
144151
AtomicBitmap {
145152
map,
146153
size: self.size,
154+
byte_size: self.byte_size,
147155
page_size: self.page_size,
148156
}
149157
}

0 commit comments

Comments
 (0)