From 1d80d1e3268f15d45b2741c2ee50eecbda5b4ca0 Mon Sep 17 00:00:00 2001 From: VitalyR Date: Wed, 7 May 2025 17:58:48 +0800 Subject: [PATCH 1/2] replace `async-std` with `async-io` --- Cargo.toml | 2 +- examples/async_tasks/async_compute.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a3d3a2ab63e51..55f59fbe502f8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -563,7 +563,7 @@ bevy_image = { path = "crates/bevy_image", version = "0.16.0-dev", default-featu bevy_gizmos = { path = "crates/bevy_gizmos", version = "0.16.0-dev", default-features = false } # Needed to poll Task examples futures-lite = "2.0.1" -async-std = "1.13" +async-io = "2" crossbeam-channel = "0.5.0" argh = "0.1.12" thiserror = "2.0" diff --git a/examples/async_tasks/async_compute.rs b/examples/async_tasks/async_compute.rs index 0b5a044563528..297afa350d0a7 100644 --- a/examples/async_tasks/async_compute.rs +++ b/examples/async_tasks/async_compute.rs @@ -62,7 +62,7 @@ fn spawn_tasks(mut commands: Commands) { let duration = Duration::from_secs_f32(rand::thread_rng().gen_range(0.05..5.0)); // Pretend this is a time-intensive function. :) - async_std::task::sleep(duration).await; + async_io::Timer::after(duration).await; // Such hard work, all done! let transform = Transform::from_xyz(x as f32, y as f32, z as f32); From 859c6fea7b036e28576908056f36431fdabb8fc4 Mon Sep 17 00:00:00 2001 From: VitalyR Date: Tue, 26 Aug 2025 15:59:09 +0800 Subject: [PATCH 2/2] use futures-timer instead of async-io to sleep for a while for a async task --- Cargo.toml | 2 +- examples/async_tasks/async_compute.rs | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 59bd88b59574c..a2df406f5c80f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -629,7 +629,7 @@ bevy_image = { path = "crates/bevy_image", version = "0.17.0-dev", default-featu bevy_gizmos = { path = "crates/bevy_gizmos", version = "0.17.0-dev", default-features = false } # Needed to poll Task examples futures-lite = "2.0.1" -async-io = "2" +futures-timer = { version = "3", features = ["wasm-bindgen", "gloo-timers"] } crossbeam-channel = "0.5.0" argh = "0.1.12" thiserror = "2.0" diff --git a/examples/async_tasks/async_compute.rs b/examples/async_tasks/async_compute.rs index 8b8e7b9622e72..50bb7c70319c6 100644 --- a/examples/async_tasks/async_compute.rs +++ b/examples/async_tasks/async_compute.rs @@ -6,6 +6,7 @@ use bevy::{ prelude::*, tasks::{block_on, futures_lite::future, AsyncComputeTaskPool, Task}, }; +use futures_timer::Delay; use rand::Rng; use std::time::Duration; @@ -62,7 +63,7 @@ fn spawn_tasks(mut commands: Commands) { let duration = Duration::from_secs_f32(rand::rng().random_range(0.05..5.0)); // Pretend this is a time-intensive function. :) - async_io::Timer::after(duration).await; + Delay::new(duration).await; // Such hard work, all done! let transform = Transform::from_xyz(x as f32, y as f32, z as f32);