pub struct BuddyBlock {
pub ptr: *mut u8,
pub size: usize,
pub order: usize,
pub is_allocated: bool,
pub allocated_at: Option<Instant>,
pub last_accessed: Option<Instant>,
pub access_count: u64,
}Expand description
Buddy block representation
Fields§
§ptr: *mut u8Block address
size: usizeBlock size (always power of 2)
order: usizeBlock order (log2 of size / min_block_size)
is_allocated: boolWhether block is allocated
allocated_at: Option<Instant>Allocation timestamp
last_accessed: Option<Instant>Last access timestamp
access_count: u64Access count
Implementations§
Source§impl BuddyBlock
impl BuddyBlock
pub fn new(ptr: *mut u8, size: usize, order: usize) -> Self
pub fn allocate(&mut self)
pub fn deallocate(&mut self)
pub fn access(&mut self)
Sourcepub fn get_buddy_address(&self, min_block_size: usize) -> *mut u8
pub fn get_buddy_address(&self, min_block_size: usize) -> *mut u8
Get buddy address for this block
Sourcepub fn is_buddy_of(&self, other: &BuddyBlock, min_block_size: usize) -> bool
pub fn is_buddy_of(&self, other: &BuddyBlock, min_block_size: usize) -> bool
Check if two blocks are buddies
Trait Implementations§
Source§impl Clone for BuddyBlock
impl Clone for BuddyBlock
Source§fn clone(&self) -> BuddyBlock
fn clone(&self) -> BuddyBlock
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for BuddyBlock
impl RefUnwindSafe for BuddyBlock
impl !Send for BuddyBlock
impl !Sync for BuddyBlock
impl Unpin for BuddyBlock
impl UnsafeUnpin for BuddyBlock
impl UnwindSafe for BuddyBlock
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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