pub struct LockedFrameAllocator(_);
Expand description
A locked version of FrameAllocator
Usage
Create a locked frame allocator and add frames to it:
use buddy_system_allocator::*;
let mut frame = LockedFrameAllocator::new();
assert!(frame.lock().alloc(1).is_none());
frame.lock().add_frame(0, 3);
let num = frame.lock().alloc(1);
assert_eq!(num, Some(2));
let num = frame.lock().alloc(2);
assert_eq!(num, Some(0));
Implementations
sourceimpl LockedFrameAllocator
impl LockedFrameAllocator
sourcepub fn new() -> LockedFrameAllocator
pub fn new() -> LockedFrameAllocator
Creates an empty heap
Methods from Deref<Target = Mutex<FrameAllocator>>
sourcepub fn is_locked(&self) -> bool
pub fn is_locked(&self) -> bool
Returns true
if the lock is currently held.
Safety
This function provides no synchronization guarantees and so its result should be considered ‘out of date’ the instant it is called. Do not use it for synchronization purposes. However, it may be useful as a heuristic.
sourcepub fn lock(&self) -> MutexGuard<'_, T>
pub fn lock(&self) -> MutexGuard<'_, T>
Locks the Mutex
and returns a guard that permits access to the inner data.
The returned value may be dereferenced for data access and the lock will be dropped when the guard falls out of scope.
let lock = spin::Mutex::new(0);
{
let mut data = lock.lock();
// The lock is now locked and the data can be accessed
*data += 1;
// The lock is implicitly dropped at the end of the scope
}
sourcepub unsafe fn force_unlock(&self)
pub unsafe fn force_unlock(&self)
sourcepub fn try_lock(&self) -> Option<MutexGuard<'_, T>>
pub fn try_lock(&self) -> Option<MutexGuard<'_, T>>
Trait Implementations
sourceimpl Deref for LockedFrameAllocator
impl Deref for LockedFrameAllocator
type Target = Mutex<FrameAllocator>
type Target = Mutex<FrameAllocator>
The resulting type after dereferencing.
sourcefn deref(&self) -> &Mutex<FrameAllocator>
fn deref(&self) -> &Mutex<FrameAllocator>
Dereferences the value.
Auto Trait Implementations
impl !RefUnwindSafe for LockedFrameAllocator
impl Send for LockedFrameAllocator
impl Sync for LockedFrameAllocator
impl Unpin for LockedFrameAllocator
impl UnwindSafe for LockedFrameAllocator
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more