Skip to main content

BufferManager

Struct BufferManager 

Source
pub struct BufferManager { /* private fields */ }
Expand description

The central unified buffer manager.

Manages memory allocation across all subsystems with pressure-aware eviction and optional spilling support.

Implementations§

Source§

impl BufferManager

Source

pub fn new(config: BufferManagerConfig) -> Arc<Self>

Creates a new buffer manager with the given configuration.

Source

pub fn with_defaults() -> Arc<Self>

Creates a buffer manager with default configuration.

Source

pub fn with_budget(budget: usize) -> Arc<Self>

Creates a buffer manager with a specific budget.

Source

pub fn try_allocate( self: &Arc<Self>, size: usize, region: MemoryRegion, ) -> Option<MemoryGrant>

Attempts to allocate memory for the given region.

Returns None if allocation would exceed the hard limit after eviction attempts.

Source

pub fn pressure_level(&self) -> PressureLevel

Returns the current pressure level.

Source

pub fn stats(&self) -> BufferStats

Returns current buffer statistics.

Source

pub fn register_consumer(&self, consumer: Arc<dyn MemoryConsumer>)

Registers a memory consumer for eviction callbacks.

Source

pub fn unregister_consumer(&self, name: &str)

Unregisters a memory consumer by name.

Source

pub fn evict_to_target(&self, target_bytes: usize) -> usize

Forces eviction to reach the target usage.

Returns the number of bytes actually freed.

Source

pub fn config(&self) -> &BufferManagerConfig

Returns the configuration.

Source

pub fn budget(&self) -> usize

Returns the memory budget.

Source

pub fn allocated(&self) -> usize

Returns currently allocated bytes.

Source

pub fn available(&self) -> usize

Returns available bytes.

Source

pub fn shutdown(&self)

Shuts down the buffer manager.

Trait Implementations§

Source§

impl Drop for BufferManager

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl GrantReleaser for BufferManager

Source§

fn release(&self, size: usize, region: MemoryRegion)

Releases memory back to the manager.
Source§

fn try_allocate_raw(&self, size: usize, region: MemoryRegion) -> bool

Tries to allocate additional memory (for resize operations).

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