From 676c23bfbba581321efcdb14b09fc606418963a2 Mon Sep 17 00:00:00 2001 From: NthTensor Date: Tue, 24 Jun 2025 09:32:52 -0400 Subject: [PATCH] Add is_finished method to wasm tasks --- crates/bevy_tasks/src/wasm_task.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/bevy_tasks/src/wasm_task.rs b/crates/bevy_tasks/src/wasm_task.rs index 0cc569c479..86dbc05bc2 100644 --- a/crates/bevy_tasks/src/wasm_task.rs +++ b/crates/bevy_tasks/src/wasm_task.rs @@ -31,6 +31,12 @@ impl Task { /// This is only included for feature parity with other platforms. pub fn detach(self) {} + /// Returns true if the current task is finished. + pub fn is_finished(&self) -> bool { + // Returns true if the result is ready or has already been accessed. + !self.0.is_empty() || self.0.is_terminated() + } + /// Requests a task to be cancelled and returns a future that suspends until it completes. /// Returns the output of the future if it has already completed. ///