pub struct FrequencyTicker { /* private fields */ }Expand description
Ticker with the given frequency.
Creates tick iterators on each step that emits ClockSteps with exactly given frequency.
Implementations§
Source§impl FrequencyTicker
impl FrequencyTicker
Sourcepub fn new(freq: Frequency, now: TimeStamp) -> Self
pub fn new(freq: Frequency, now: TimeStamp) -> Self
Creates new ticker with given frequency and start timestamp.
Sourcepub fn with_delay(freq: Frequency, periods: u64, now: TimeStamp) -> Self
pub fn with_delay(freq: Frequency, periods: u64, now: TimeStamp) -> Self
Creates new ticker with given frequency and delay in number of tick periods.
Sourcepub fn next_tick(&self) -> Option<TimeStamp>
pub fn next_tick(&self) -> Option<TimeStamp>
Returns next timestamp when next tick will happen.
Sourcepub fn ticks(&mut self, step: TimeSpan) -> FrequencyTickerIter ⓘ
pub fn ticks(&mut self, step: TimeSpan) -> FrequencyTickerIter ⓘ
Advances ticker forward for span and returns iterator over ticks
since last advancement.
Sourcepub fn tick_count(&mut self, step: TimeSpan) -> u64
pub fn tick_count(&mut self, step: TimeSpan) -> u64
Advances ticker forward to now and returns number of ticks
since last advancement.
Sourcepub fn with_ticks(&mut self, step: TimeSpan, f: impl FnMut(ClockStep))
pub fn with_ticks(&mut self, step: TimeSpan, f: impl FnMut(ClockStep))
Advances ticker forward for step and calls provided closure with ClockSteps.
Sourcepub fn set_frequency(&mut self, freq: Frequency, clip_period: bool)
pub fn set_frequency(&mut self, freq: Frequency, clip_period: bool)
Sets new frequency of the ticker.
If clip_period is true, then next tick will happen at least in the frequency period.
If clip_period is false, then next tick will happen at the same time as before setting the frequency.