pub struct CapacityAllocator { /* private fields */ }Expand description
A reusable capacity allocator for object counts, bytes, or other units.
Implementations§
Source§impl CapacityAllocator
impl CapacityAllocator
Sourcepub fn new(
parent: &Rc<Entity>,
name: &str,
capacity: usize,
capacity_unit: impl Into<String>,
) -> Result<Self, SimError>
pub fn new( parent: &Rc<Entity>, name: &str, capacity: usize, capacity_unit: impl Into<String>, ) -> Result<Self, SimError>
Create a standalone allocator with its own child entity.
Sourcepub fn for_entity(
entity: &Rc<Entity>,
capacity: usize,
capacity_unit: impl Into<String>,
) -> Result<Self, SimError>
pub fn for_entity( entity: &Rc<Entity>, capacity: usize, capacity_unit: impl Into<String>, ) -> Result<Self, SimError>
Create allocator bookkeeping on an existing entity.
pub fn used(&self) -> usize
pub fn capacity(&self) -> usize
pub fn capacity_unit(&self) -> &str
pub fn level_change_event(&self) -> Repeated<usize>
pub async fn wait_for_capacity(&self, units: usize) -> SimResult
pub fn allocate(&self, units: usize) -> SimResult
pub fn release(&self, units: usize)
pub async fn reserve( &self, units: usize, ) -> Result<CapacityReservation, SimError>
Trait Implementations§
Source§impl Clone for CapacityAllocator
impl Clone for CapacityAllocator
Source§fn clone(&self) -> CapacityAllocator
fn clone(&self) -> CapacityAllocator
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Display for CapacityAllocator
impl Display for CapacityAllocator
Auto Trait Implementations§
impl !RefUnwindSafe for CapacityAllocator
impl !Send for CapacityAllocator
impl !Sync for CapacityAllocator
impl !UnwindSafe for CapacityAllocator
impl Freeze for CapacityAllocator
impl Unpin for CapacityAllocator
impl UnsafeUnpin for CapacityAllocator
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