Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ticked_async_executor"
version = "0.2.0"
version = "0.2.1"
authors = ["coder137"]
edition = "2021"
description = "Local executor that runs woken async tasks when it is ticked"
Expand Down
2 changes: 1 addition & 1 deletion src/split_ticked_async_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ where

pub fn create_timer(&self) -> TickedTimer {
let tick_recv = self.rx_tick_event.clone();
TickedTimer { tick_recv }
TickedTimer::new(tick_recv)
}

pub fn tick_channel(&self) -> tokio::sync::watch::Receiver<f64> {
Expand Down
6 changes: 5 additions & 1 deletion src/ticked_timer.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
pub struct TickedTimer {
pub tick_recv: tokio::sync::watch::Receiver<f64>,
tick_recv: tokio::sync::watch::Receiver<f64>,
}

impl TickedTimer {
pub fn new(tick_recv: tokio::sync::watch::Receiver<f64>) -> Self {
Self { tick_recv }
}

pub async fn sleep_for(mut self, mut duration_in_ms: f64) {
loop {
let _r = self.tick_recv.changed().await;
Expand Down