pub struct TimingGroup<C: TimerCount> { /* private fields */ }Expand description
Helper for equally dividing time slots across multiple entries manually.
This struct can be used to control time usage of some arbitrary entries and to ensure they have
more-less equal amount of time per slot to assign. LoadBalance
group uses this struct to split time slots between tasks.
You can use custom time units by implementing trait TimerCount.
Implementations§
Source§impl<C: TimerCount> TimingGroup<C>
impl<C: TimerCount> TimingGroup<C>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create new empty instance of TimingGroup that can contain at least capacity number of
entries without reallocating.
Sourcepub fn insert(&mut self, slot_count: u16) -> usize
pub fn insert(&mut self, slot_count: u16) -> usize
Insert entry to timing group with specific number of time slots and obtain its key.
§Panics
Panics if time slot count argument is zero.
Sourcepub fn remove(&mut self, key: usize)
pub fn remove(&mut self, key: usize)
Remove entry with specific key from this timing group.
§Panics
Panics if provided key has no associated entry.
Sourcepub fn contains(&self, key: usize) -> bool
pub fn contains(&self, key: usize) -> bool
Checks if specific key has an entry associated to it in this group.
Sourcepub fn get_slot_count(&self, key: usize) -> Option<u16>
pub fn get_slot_count(&self, key: usize) -> Option<u16>
Returns time slot count for given key or None if this key is invalid.
Sourcepub fn can_execute(&self, key: usize) -> bool
pub fn can_execute(&self, key: usize) -> bool
Check if entry with specific key can be executed now.
§Panics
Panics if provided key has no associated entry.
Sourcepub fn update_duration(&mut self, key: usize, dur: C)
pub fn update_duration(&mut self, key: usize, dur: C)
Update execution duration of entry with specific key.
§Panics
Panics if provided key has no associated entry.