Struct customizable_buddy::BuddyAllocator
source · [−]pub struct BuddyAllocator<const N: usize, O: OligarchyCollection, B: BuddyCollection> { /* private fields */ }Expand description
伙伴分配器。
Implementations
sourceimpl<const N: usize, O: OligarchyCollection, B: BuddyCollection> BuddyAllocator<N, O, B>
impl<const N: usize, O: OligarchyCollection, B: BuddyCollection> BuddyAllocator<N, O, B>
sourcepub fn snatch<T>(
&mut self,
align_order: usize,
size: NonZeroUsize
) -> Result<(NonNull<T>, usize), BuddyError>
pub fn snatch<T>(
&mut self,
align_order: usize,
size: NonZeroUsize
) -> Result<(NonNull<T>, usize), BuddyError>
从分配器夺走一个对齐到 align_order 阶,长度为 size 的内存块。
sourcepub fn allocate_type<T>(&mut self) -> Result<(NonNull<T>, usize), BuddyError>
pub fn allocate_type<T>(&mut self) -> Result<(NonNull<T>, usize), BuddyError>
分配可容纳 T 对象的内存块。
sourcepub fn allocate_layout<T>(
&mut self,
layout: Layout
) -> Result<(NonNull<T>, usize), BuddyError>
pub fn allocate_layout<T>(
&mut self,
layout: Layout
) -> Result<(NonNull<T>, usize), BuddyError>
分配符合 layout 布局的内存块。
sourcepub fn allocate<T>(
&mut self,
align_order: usize,
size: NonZeroUsize
) -> Result<(NonNull<T>, usize), BuddyError>
pub fn allocate<T>(
&mut self,
align_order: usize,
size: NonZeroUsize
) -> Result<(NonNull<T>, usize), BuddyError>
分配。
如果分配成功,返回一个 (指针, 长度) 二元组。
sourcepub unsafe fn deallocate_layout<T>(&mut self, ptr: NonNull<T>, layout: Layout)
pub unsafe fn deallocate_layout<T>(&mut self, ptr: NonNull<T>, layout: Layout)
sourcepub fn deallocate<T>(&mut self, ptr: NonNull<T>, size: usize)
pub fn deallocate<T>(&mut self, ptr: NonNull<T>, size: usize)
Trait Implementations
sourceimpl<const N: usize, O: OligarchyCollection + Debug, B: BuddyCollection + Debug> Debug for BuddyAllocator<N, O, B>
impl<const N: usize, O: OligarchyCollection + Debug, B: BuddyCollection + Debug> Debug for BuddyAllocator<N, O, B>
Auto Trait Implementations
impl<const N: usize, O, B> RefUnwindSafe for BuddyAllocator<N, O, B>where
B: RefUnwindSafe,
O: RefUnwindSafe,
impl<const N: usize, O, B> Send for BuddyAllocator<N, O, B>where
B: Send,
O: Send,
impl<const N: usize, O, B> Sync for BuddyAllocator<N, O, B>where
B: Sync,
O: Sync,
impl<const N: usize, O, B> Unpin for BuddyAllocator<N, O, B>where
B: Unpin,
O: Unpin,
impl<const N: usize, O, B> UnwindSafe for BuddyAllocator<N, O, B>where
B: UnwindSafe,
O: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more