Skip to content

Commit

Permalink
Merge pull request #378 from nervosnetwork/fix-interval-inconsistent-…
Browse files Browse the repository at this point in the history
…behavior

fix: Fix interval inconsistent behavior
  • Loading branch information
driftluo authored Nov 20, 2024
2 parents 8cf4f13 + ef76235 commit f4baf2a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tentacle/src/runtime/tokio_runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ mod time {
task::{Context, Poll},
time::Duration,
};
use tokio::time::{interval as inner_interval, Interval as Inner, MissedTickBehavior};
use tokio::time::{
interval_at as inner_interval, Instant, Interval as Inner, MissedTickBehavior,
};

pub struct Interval(Inner);

impl Interval {
pub fn new(period: Duration) -> Self {
Self(inner_interval(period))
Self(inner_interval(Instant::now() + period, period))
}

pub fn set_missed_tick_behavior(&mut self, behavior: MissedTickBehavior) {
Expand Down

0 comments on commit f4baf2a

Please sign in to comment.