pub struct LockedHeap(_);

Implementations§

Safety

This function is unsafe because it can cause undefined behavior if the given address is invalid.

Creates a new heap with the given heap_start_addr and heap_size. The start address must be valid and the memory in the [heap_start_addr, heap_bottom + heap_size) range must not be used for anything else.

Safety

This function is unsafe because it can cause undefined behavior if the given address is invalid.

Methods from Deref<Target = Mutex<Option<Heap>>>§

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
}

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.

Force unlock this Mutex.

Safety

This is extremely unsafe if the lock is not held by the current thread. However, this can be useful in some instances for exposing the lock to FFI that doesn’t know how to deal with RAII.

Try to lock this Mutex, returning a lock guard if successful.

Example
let lock = spin::Mutex::new(42);

let maybe_guard = lock.try_lock();
assert!(maybe_guard.is_some());

// `maybe_guard` is still held, so the second call fails
let maybe_guard2 = lock.try_lock();
assert!(maybe_guard2.is_none());

Trait Implementations§

The resulting type after dereferencing.
Dereferences the value.
Allocate memory as described by the given layout. Read more
Deallocate the block of memory at the given ptr pointer with the given layout. Read more
Behaves like alloc, but also ensures that the contents are set to zero before being returned. Read more
Shrink or grow a block of memory to the given new_size. The block is described by the given ptr pointer and layout. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.