Skip to content

Commit 2600df2

Browse files
authored
TickedTimer new API (#13)
1 parent 38771a4 commit 2600df2

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ticked_async_executor"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
authors = ["coder137"]
55
edition = "2021"
66
description = "Local executor that runs woken async tasks when it is ticked"

src/split_ticked_async_executor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ where
8989

9090
pub fn create_timer(&self) -> TickedTimer {
9191
let tick_recv = self.rx_tick_event.clone();
92-
TickedTimer { tick_recv }
92+
TickedTimer::new(tick_recv)
9393
}
9494

9595
pub fn tick_channel(&self) -> tokio::sync::watch::Receiver<f64> {

src/ticked_timer.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
pub struct TickedTimer {
2-
pub tick_recv: tokio::sync::watch::Receiver<f64>,
2+
tick_recv: tokio::sync::watch::Receiver<f64>,
33
}
44

55
impl TickedTimer {
6+
pub fn new(tick_recv: tokio::sync::watch::Receiver<f64>) -> Self {
7+
Self { tick_recv }
8+
}
9+
610
pub async fn sleep_for(mut self, mut duration_in_ms: f64) {
711
loop {
812
let _r = self.tick_recv.changed().await;

0 commit comments

Comments
 (0)