1
我是新来的,现在学习Rust,来自Go。我如何实现诸如长时间并发轮询之类的东西?什么是Go的范围time.Tick?
// StartGettingWeather initialize weather getter and setter
func StartGettingWeather() {
// start looping
for i := range time.Tick(time.Second * time.Duration(delay)) {
_ = i
loopCounter++
fmt.Println(time.Now().Format(time.RFC850), " counter: ", loopCounter)
mainWeatherGetter()
}
}
,我会打电话给本功能为go StartGettingWeather()
曾经有一个计时器在标准,但现在它已被弃用。你可以看看这个箱子的更换:https://github.com/PeterReid/timer。 periodic_ms应该或多或少地像时间一样工作。挑战 –