From d0c9e2197ab978183f8d4a29ee574d76e14d0671 Mon Sep 17 00:00:00 2001 From: Noah Date: Wed, 15 Nov 2023 09:29:43 -0500 Subject: [PATCH] Make FakeTask public on singlethreaded context (#10517) # Objective - When compiling bevy for both singlethreaded and multithreaded contexts and using `Task` directly, you can run into errors where you expect a `Task` to be returned but `FakeTask` is instead. Due to `FakeTask` being private the only solution is to ignore the return at all however because it *is* returned that isn't totally clear. The error is confusing and doesn't provide a solution or help figuring it out. ## Solution - Made `FakeTask` public and added brief documentation providing a use (none) that helps guide usage (no usage) of FakeTask. --- crates/bevy_tasks/src/lib.rs | 2 +- crates/bevy_tasks/src/single_threaded_task_pool.rs | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/bevy_tasks/src/lib.rs b/crates/bevy_tasks/src/lib.rs index d4b68e2096..4d2786e41a 100644 --- a/crates/bevy_tasks/src/lib.rs +++ b/crates/bevy_tasks/src/lib.rs @@ -16,7 +16,7 @@ pub use task_pool::{Scope, TaskPool, TaskPoolBuilder}; #[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))] mod single_threaded_task_pool; #[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))] -pub use single_threaded_task_pool::{Scope, TaskPool, TaskPoolBuilder, ThreadExecutor}; +pub use single_threaded_task_pool::{FakeTask, Scope, TaskPool, TaskPoolBuilder, ThreadExecutor}; mod usages; #[cfg(not(target_arch = "wasm32"))] diff --git a/crates/bevy_tasks/src/single_threaded_task_pool.rs b/crates/bevy_tasks/src/single_threaded_task_pool.rs index 9555a6a470..81c26a1bc4 100644 --- a/crates/bevy_tasks/src/single_threaded_task_pool.rs +++ b/crates/bevy_tasks/src/single_threaded_task_pool.rs @@ -186,6 +186,9 @@ impl TaskPool { } } +/// An empty task used in single-threaded contexts. +/// +/// This does nothing and is therefore safe, and recommended, to ignore. #[derive(Debug)] pub struct FakeTask;