This commit is contained in:
John Smith
2022-01-27 09:53:01 -05:00
parent 1decd333c8
commit 7ef6d407a5
13 changed files with 702 additions and 907 deletions

View File

@@ -32,6 +32,14 @@ impl TickTask {
single_future: SingleFuture::new(),
}
}
pub fn new_ms(tick_period_ms: u32) -> Self {
Self {
last_timestamp_us: AtomicU64::new(0),
tick_period_us: (tick_period_ms as u64) * 1000u64,
routine: OnceCell::new(),
single_future: SingleFuture::new(),
}
}
pub fn new(tick_period_sec: u32) -> Self {
Self {
last_timestamp_us: AtomicU64::new(0),

View File

@@ -41,6 +41,10 @@ pub fn secs_to_timestamp(secs: f64) -> u64 {
(secs * 1000000.0f64) as u64
}
pub fn ms_to_us(ms: u32) -> u64 {
(ms as u64) * 1000u64
}
// Calculate retry attempt with logarhythmic falloff
pub fn retry_falloff_log(
last_us: u64,