pub struct BufferPool { /* private fields */ }Expand description
A pool that hands out reusable buffers for prover working memory.
Allocation goes through alloc_vec. Freed buffers are kept on an internal
free list, keyed by block size (in AlignedChunks), and reused to satisfy later allocations
of the same size. A pool is created once, above the code that uses it, and shared by borrow —
every PoolVec it produces holds a &'alloc BufferPool. The pool is thread-safe: the free
list sits behind a Mutex, so allocation and reclamation may happen from any thread.
Implementations§
Source§impl BufferPool
impl BufferPool
Sourcepub fn alloc_vec<T>(&self, capacity: usize) -> PoolVec<'_, T>
pub fn alloc_vec<T>(&self, capacity: usize) -> PoolVec<'_, T>
Allocates a PoolVec with room for at least capacity elements.
The block size is rounded up to a power-of-two number of bytes. If the free list holds a
block of that size it is reused; otherwise a fresh block is allocated. The returned buffer
is empty; fill it through the PoolVec interface.
§Panics
Panics at compile time (via a const assertion) if T’s alignment exceeds BUFFER_ALIGN,
or if T’s size is not a power of two — either would break the byte-size keyed reuse.
Trait Implementations§
Source§impl<'alloc> Allocator for &'alloc BufferPool
impl<'alloc> Allocator for &'alloc BufferPool
Source§impl Debug for BufferPool
impl Debug for BufferPool
Source§impl Default for BufferPool
impl Default for BufferPool
Source§fn default() -> BufferPool
fn default() -> BufferPool
Auto Trait Implementations§
impl !Freeze for BufferPool
impl RefUnwindSafe for BufferPool
impl Send for BufferPool
impl Sync for BufferPool
impl Unpin for BufferPool
impl UnsafeUnpin for BufferPool
impl UnwindSafe for BufferPool
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
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