pub struct BufferPoolBuilder { /* private fields */ }Expand description
Builder for creating a BufferPool with custom configuration.
§Example
use ruapc_bufpool::BufferPoolBuilder;
let pool = BufferPoolBuilder::new()
.max_memory(512 * 1024 * 1024) // 512 MiB
.build();Implementations§
Source§impl BufferPoolBuilder
impl BufferPoolBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new builder with default settings.
Default settings:
- Max memory: 256 MiB
- Allocator:
DefaultAllocator
Sourcepub const fn max_memory(self, max_memory: usize) -> Self
pub const fn max_memory(self, max_memory: usize) -> Self
Sets the maximum memory limit for the pool.
When this limit is reached:
- Synchronous allocations will return an error
- Asynchronous allocations will wait for memory to be freed
The limit should be a multiple of 64 MiB for optimal utilization.
Sourcepub fn allocator(self, allocator: Box<dyn Allocator>) -> Self
pub fn allocator(self, allocator: Box<dyn Allocator>) -> Self
Sets a custom allocator for the pool.
The allocator is used to allocate and deallocate the underlying 64 MiB memory blocks.
Sourcepub fn build(self) -> Arc<BufferPool>
pub fn build(self) -> Arc<BufferPool>
Builds the buffer pool with the configured settings.
Returns an Arc<BufferPool> to enable efficient sharing across threads
and ensure buffers can maintain references to their owning pool.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BufferPoolBuilder
impl !RefUnwindSafe for BufferPoolBuilder
impl Send for BufferPoolBuilder
impl Sync for BufferPoolBuilder
impl Unpin for BufferPoolBuilder
impl !UnwindSafe for BufferPoolBuilder
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