pub struct KvPagePool {
pub bytes_per_page: usize,
pub tokens_per_page: u16,
/* private fields */
}Expand description
Pool of fixed-size physical pages. Allocates from a free list;
free returns a page so the next allocation can reuse it.
Pool capacity is num_pages * bytes_per_page. Caller owns the
underlying byte arena (typically a single large MTLBuffer or
host Vec); the pool tracks which IDs are free.
Fields§
§bytes_per_page: usizeConstants exposed for ergonomics.
tokens_per_page: u16Implementations§
Source§impl KvPagePool
impl KvPagePool
pub fn new(num_pages: u32, bytes_per_page: usize, tokens_per_page: u16) -> Self
pub fn capacity(&self) -> u32
pub fn free_count(&self) -> u32
pub fn used_count(&self) -> u32
Sourcepub fn alloc(&mut self) -> Option<KvPageId>
pub fn alloc(&mut self) -> Option<KvPageId>
Allocate one page. Returns None when the pool is empty.
pub fn free(&mut self, id: KvPageId)
pub fn descriptor(&self, id: KvPageId) -> &KvPageDesc
pub fn descriptor_mut(&mut self, id: KvPageId) -> &mut KvPageDesc
Auto Trait Implementations§
impl Freeze for KvPagePool
impl RefUnwindSafe for KvPagePool
impl Send for KvPagePool
impl Sync for KvPagePool
impl Unpin for KvPagePool
impl UnsafeUnpin for KvPagePool
impl UnwindSafe for KvPagePool
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
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>
Converts
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>
Converts
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