Skip to main content

TimingGroup

Struct TimingGroup 

Source
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>

Source

pub fn new() -> Self

Create new empty instance of TimingGroup.

Source

pub fn with_capacity(capacity: usize) -> Self

Create new empty instance of TimingGroup that can contain at least capacity number of entries without reallocating.

Source

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.

Source

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.

Source

pub fn contains(&self, key: usize) -> bool

Checks if specific key has an entry associated to it in this group.

Source

pub fn count(&self) -> usize

Returns number of registered entries in this group.

Source

pub fn get_slot_count(&self, key: usize) -> Option<u16>

Returns time slot count for given key or None if this key is invalid.

Source

pub fn clear(&mut self)

Remove all entries from this group and reset its state.

Source

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.

Source

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.

Trait Implementations§

Source§

impl<C: TimerCount + Debug> Debug for TimingGroup<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<C> Freeze for TimingGroup<C>
where C: Freeze,

§

impl<C> RefUnwindSafe for TimingGroup<C>
where C: RefUnwindSafe,

§

impl<C> Send for TimingGroup<C>
where C: Send,

§

impl<C> Sync for TimingGroup<C>
where C: Sync,

§

impl<C> Unpin for TimingGroup<C>
where C: Unpin,

§

impl<C> UnsafeUnpin for TimingGroup<C>
where C: UnsafeUnpin,

§

impl<C> UnwindSafe for TimingGroup<C>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.