Skip to main content

RegionAllocator

Struct RegionAllocator 

Source
pub struct RegionAllocator { /* private fields */ }

Implementations§

Source§

impl RegionAllocator

Source

pub fn project<'__pin>( self: Pin<&'__pin mut Self>, ) -> RegionAllocatorProjection<'__pin>

Pin-projects all fields of Self.

These fields are structurally pinned:

  • mu
  • allocated_regions_by_base
  • avail_regions_by_base
  • avail_regions_by_size

These fields are not structurally pinned:

  • region_pool
Source§

impl RegionAllocator

Source

pub fn lock_mu(&self) -> impl PinInit<RegionAllocatorMuGuard<'_>, Infallible>

Source

pub fn lock_mu_policy<P: LockPolicy<RawMutex, AcquireArgs = ()>>( &self, ) -> impl PinInit<RegionAllocatorMuGuard<'_, P>, Infallible>

Source

pub fn lock_mu_aliased<'a, AliasClass: LockClass, M2: RawLock>( &'a self, alias: &'a KMutex<AliasClass, M2>, ) -> impl PinInit<KMutexAliasedGuard<'a, RegionAllocatorMuClass, AliasClass, RawMutex, M2>, Infallible>

Source

pub fn lock_mu_aliased_policy<'a, AliasClass: LockClass, M2: RawLock, P: LockPolicy<RawMutex, AcquireArgs = ()>>( &'a self, alias: &'a KMutex<AliasClass, M2>, ) -> impl PinInit<KMutexAliasedGuard<'a, RegionAllocatorMuClass, AliasClass, RawMutex, M2, P>, Infallible>

Source

pub fn guard_mu<'b, 'a>( &'b self, token: &'b LockToken<'a, RegionAllocatorMuClass>, ) -> RegionAllocatorMuTokenGuard<'b, 'a>

Source

pub fn guard_mu_mut<'b, 'a>( &'b self, token: &'b mut LockToken<'a, RegionAllocatorMuClass>, ) -> RegionAllocatorMuTokenGuardMut<'b, 'a>

Source§

impl RegionAllocator

Source

pub const REGION_POOL_SLAB_SIZE: usize = 4096

Source

pub fn init() -> impl PinInit<Self, Infallible>

Source

pub fn init_with_pool( pool: RefPtr<RegionPool>, ) -> impl PinInit<Self, Infallible>

Initialize a RegionAllocator with a specified RegionPool.

Source

pub fn has_region_pool(&self) -> bool

Source

pub fn set_region_pool(&self, pool: RefPtr<RegionPool>) -> Result<(), Status>

Source

pub fn reset(&self)

Source

pub fn add_region( &self, region: RegionSpan, allow_overlap: AllowOverlap, ) -> Result<(), Status>

Source

pub fn subtract_region( &self, to_subtract: RegionSpan, allow_incomplete: AllowIncomplete, ) -> Result<(), Status>

Source

pub fn get_region( &self, size: u64, alignment: u64, ) -> Result<UniquePtr<Region>, Status>

Source

pub fn get_region_pointer_aligned( &self, size: u64, ) -> Result<UniquePtr<Region>, Status>

Get a region out of the set of currently available regions which has a specified size and is pointer-aligned (aligned to core::mem::size_of::<*const ()>()).

Source

pub fn get_region_specific( &self, requested_region: RegionSpan, ) -> Result<UniquePtr<Region>, Status>

Source

pub fn test_region_intersects( &self, region: RegionSpan, which: TestRegionSet, ) -> Result<bool, Status>

Source

pub fn test_region_contained_by( &self, region: RegionSpan, which: TestRegionSet, ) -> Result<bool, Status>

Source

pub fn allocated_region_count(&self) -> usize

Source

pub fn available_region_count(&self) -> usize

Source

pub fn walk_allocated_regions<F>(&self, cb: F)
where F: FnMut(&Region) -> bool,

Walk the allocated regions and call the user provided callback for each entry. Stop when out of entries or the callback returns false.

§Warning

It is absolutely required that the user callback must not call into any other RegionAllocator public APIs, and should likely not acquire any locks of any kind. This method cannot protect against deadlocks and lock inversions that are possible by acquiring the allocation lock before calling the user provided callback. Because KMutex is not recursive, calling back into the allocator from within the callback will deadlock.

Source

pub fn walk_available_regions<F>(&self, cb: F)
where F: FnMut(&Region) -> bool,

Walk the available regions and call the user provided callback for each entry. Stop when out of entries or the callback returns false.

§Warning

It is absolutely required that the user callback must not call into any other RegionAllocator public APIs, and should likely not acquire any locks of any kind. This method cannot protect against deadlocks and lock inversions that are possible by acquiring the allocation lock before calling the user provided callback. Because KMutex is not recursive, calling back into the allocator from within the callback will deadlock.

Trait Implementations§

Source§

impl Drop for RegionAllocator

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl HasPinData for RegionAllocator

Source§

type PinData = __ThePinData

Source§

unsafe fn __pin_data() -> Self::PinData

Source§

impl PinnedDrop for RegionAllocator

Source§

fn drop(self: Pin<&mut Self>, _: OnlyCallFromDrop)

Executes the pinned destructor of this type. Read more
Source§

impl Send for RegionAllocator

Source§

impl Sync for RegionAllocator

Auto Trait Implementations§

§

impl !Freeze for RegionAllocator

§

impl !RefUnwindSafe for RegionAllocator

§

impl !UnsafeUnpin for RegionAllocator

§

impl !UnwindSafe for RegionAllocator

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Init<T> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), !>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> PinInit<T> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), !>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
§

impl<T> ToMutPtr for T
where T: ?Sized,

§

type Target = T

The target type of the pointer.
§

fn to_mut_ptr(&self) -> *mut T

Casts the reference to a mutable raw pointer.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.