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
impl BufferManager
Sourcepub fn new(config: BufferManagerConfig) -> Arc<Self>
pub fn new(config: BufferManagerConfig) -> Arc<Self>
Creates a new buffer manager with the given configuration.
Sourcepub fn with_defaults() -> Arc<Self>
pub fn with_defaults() -> Arc<Self>
Creates a buffer manager with default configuration.
Sourcepub fn with_budget(budget: usize) -> Arc<Self>
pub fn with_budget(budget: usize) -> Arc<Self>
Creates a buffer manager with a specific budget.
Sourcepub fn try_allocate(
self: &Arc<Self>,
size: usize,
region: MemoryRegion,
) -> Option<MemoryGrant>
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.
Sourcepub fn pressure_level(&self) -> PressureLevel
pub fn pressure_level(&self) -> PressureLevel
Returns the current pressure level.
Sourcepub fn stats(&self) -> BufferStats
pub fn stats(&self) -> BufferStats
Returns current buffer statistics.
Sourcepub fn register_consumer(&self, consumer: Arc<dyn MemoryConsumer>)
pub fn register_consumer(&self, consumer: Arc<dyn MemoryConsumer>)
Registers a memory consumer for eviction callbacks.
Sourcepub fn unregister_consumer(&self, name: &str)
pub fn unregister_consumer(&self, name: &str)
Unregisters a memory consumer by name.
Sourcepub fn evict_to_target(&self, target_bytes: usize) -> usize
pub fn evict_to_target(&self, target_bytes: usize) -> usize
Forces eviction to reach the target usage.
Returns the number of bytes actually freed.
Sourcepub fn config(&self) -> &BufferManagerConfig
pub fn config(&self) -> &BufferManagerConfig
Returns the configuration.
Trait Implementations§
Source§impl Drop for BufferManager
impl Drop for BufferManager
Source§impl GrantReleaser for BufferManager
impl GrantReleaser for BufferManager
Source§fn release(&self, size: usize, region: MemoryRegion)
fn release(&self, size: usize, region: MemoryRegion)
Releases memory back to the manager.
Source§fn try_allocate_raw(&self, size: usize, region: MemoryRegion) -> bool
fn try_allocate_raw(&self, size: usize, region: MemoryRegion) -> bool
Tries to allocate additional memory (for resize operations).
Auto Trait Implementations§
impl !Freeze for BufferManager
impl !RefUnwindSafe for BufferManager
impl Send for BufferManager
impl Sync for BufferManager
impl Unpin for BufferManager
impl !UnwindSafe for BufferManager
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
Mutably borrows from an owned value. Read more