pub struct ChunkMap {
space_index: usize,
chunk_range: Mutex<Range<Chunk>>,
}
Expand description
A byte-map to record all the allocated chunks.
A plan can use this to maintain records for the chunks that they used, and the states of the chunks.
Any plan that uses the chunk map should include the ALLOC_TABLE
spec in their global sidemetadata specs.
A chunk map is created for a space (identified by the space index), and will only update or list chunks for that space.
Fields§
§space_index: usize
The space that uses this chunk map.
chunk_range: Mutex<Range<Chunk>>
The range of chunks that are used by the space. The range only records the lowest chunk and the highest chunk. All the chunks that are used for the space are within the range, but not necessarily that all the chunks in the range are used for the space. Spaces may be discontiguous, thus the range may include chunks that do not belong to the space. We need to use the space index in the chunk map and the space index encoded with the chunk state to know if the chunk belongs to the current space.
Implementations§
source§impl ChunkMap
impl ChunkMap
sourcepub const ALLOC_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::CHUNK_MARK
pub const ALLOC_TABLE: SideMetadataSpec = crate::util::metadata::side_metadata::spec_defs::CHUNK_MARK
Chunk alloc table
pub fn new(space_index: usize) -> Self
sourcepub fn set_allocated(&self, chunk: Chunk, allocated: bool)
pub fn set_allocated(&self, chunk: Chunk, allocated: bool)
Set a chunk as allocated, or as free.
sourcepub fn get(&self, chunk: Chunk) -> Option<ChunkState>
pub fn get(&self, chunk: Chunk) -> Option<ChunkState>
Get chunk state. Return None if the chunk does not belong to the space.
sourcefn get_internal(&self, chunk: Chunk) -> ChunkState
fn get_internal(&self, chunk: Chunk) -> ChunkState
Get chunk state, regardless of the space. This should always be private.
sourcepub fn all_chunks(&self) -> impl Iterator<Item = Chunk> + '_
pub fn all_chunks(&self) -> impl Iterator<Item = Chunk> + '_
A range of all allocated chunks by this space in the heap.
Auto Trait Implementations§
impl !Freeze for ChunkMap
impl !RefUnwindSafe for ChunkMap
impl Send for ChunkMap
impl Sync for ChunkMap
impl Unpin for ChunkMap
impl UnwindSafe for ChunkMap
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
, which can then be
downcast
into Box<dyn ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
, which can then be further
downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more