Skip to main content

BlockAllocator

Trait BlockAllocator 

Source
pub trait BlockAllocator: Send + Sync {
    // Required methods
    fn allocate_blocks(&self, num_blocks: usize) -> Result<Vec<BlockId>>;
    fn free_blocks(&self, blocks: &[BlockId]) -> Result<()>;
    fn free_block_count(&self) -> usize;
    fn total_block_count(&self) -> usize;
    fn block_size(&self) -> usize;
    fn defragment(&self) -> Result<()>;
}
Expand description

Block-based cache allocator

Required Methods§

Source

fn allocate_blocks(&self, num_blocks: usize) -> Result<Vec<BlockId>>

Allocate specified number of blocks

Source

fn free_blocks(&self, blocks: &[BlockId]) -> Result<()>

Free blocks back to allocator

Source

fn free_block_count(&self) -> usize

Get number of free blocks

Source

fn total_block_count(&self) -> usize

Get total block count

Source

fn block_size(&self) -> usize

Get block size in tokens

Source

fn defragment(&self) -> Result<()>

Defragment free block list

Implementors§