gpt4 book ai didi

crystal-lang - Crystal Lang 中的计时器/间隔

转载 作者:行者123 更新时间:2023-12-04 18:21:09 26 4
gpt4 key购买 nike

Crystal中是否有计时器或间隔功能?

我检查了计时器、间隔和 Time 类下的文档,但没有看到任何内容。

类似 setInterval()setTimeout()来自 JavaScript?

最佳答案

超时有 delay .请注意,用于此的 API 尚未最终确定,可能会在 future 版本中更改,甚至会再次暂时删除。

对于间隔,目前没有任何东西可以保证准确的时间,但是如果不用担心并且近似的间隔就足够了,那么这样做就很简单

spawn do
loop do
sleep INTERVAL
do_regular_work
end
end

sleep # Or some other workload, when the main fiber quits so will the program and thus all other fibers.

关于crystal-lang - Crystal Lang 中的计时器/间隔,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49359093/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com