asynchronous - 有没有办法在 Rust 异步函数体内延迟执行一段时间?

标签 asynchronous rust

我认为 std::thread::sleep(...) 在这里不是正确的用例。

最佳答案

使用tokio crate,有这个功能

tokio::time::delay_for(tokio::time::Duration::from_millis(WAIT_TIME_INTERVAL_MS));

实际上,任何执行都会等待Duration

关于asynchronous - 有没有办法在 Rust 异步函数体内延迟执行一段时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62994171/

相关文章:

android - 将文件从 Assets 复制到数据文件夹后,数据未首次在 android 中显示

wpf - 为什么在执行await 语句后无法访问我的代码?

javascript - 在 react-native 中实现 promises 和 AsyncStorage

rust - 如何结合逐行读取文件和遍历每一行中的每个字符?

rust - 为什么 Bevy 在绘制我的许多 SpriteComponent 时遇到困难?

javascript - 优化异步调用(.then() 链接)

c# - 异步 httpwebrequest 的一部分

rust - 在基本特征对象中包含特征对象

syntax - 为什么引入 dyn 语法?

pointers - 在使用 no_std 删除指针之前防止删除