You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use delay_timer::prelude::*;
use anyhow::Result;
use smol::Timer;
use std::time::Duration;
fn main() {
//1、a timer start from 1 to 50000 millisecond.
//let mut current_time= 1;
//2、if the current_time equals some numbers, do somethings.
if current_time =2000 {
//do something 1
}
if current_time =39999 {
//do something 2
}
//...
}
The text was updated successfully, but these errors were encountered:
use delay_timer::prelude::*;
use anyhow::Result;
use smol::Timer;
use std::time::Duration;
fn main() {
//1、a timer start from 1 to 50000 millisecond.
//let mut current_time= 1;
//2、if the current_time equals some numbers, do somethings.
if current_time =2000 {
//do something 1
}
if current_time =39999 {
//do something 2
}
//...
}
In this case you use tokio::time:sleep, which would be better suited than delay-timer, delay-timer which manages periodic tasks and controls the number of concurrent tasks.
Your need is for random time intervals, suitable for different sleep schemes.
Code is as follow, questions are in the code.
Cargo.toml
main.rs
The text was updated successfully, but these errors were encountered: