Skip to content

TickedTimer API #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025
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