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.
This commit is contained in:
Noah 2023-11-15 09:29:43 -05:00 committed by GitHub
parent 60bbfd78ac
commit d0c9e2197a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View File

@ -16,7 +16,7 @@ pub use task_pool::{Scope, TaskPool, TaskPoolBuilder};
#[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))] #[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))]
mod single_threaded_task_pool; mod single_threaded_task_pool;
#[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))] #[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; mod usages;
#[cfg(not(target_arch = "wasm32"))] #[cfg(not(target_arch = "wasm32"))]

View File

@ -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)] #[derive(Debug)]
pub struct FakeTask; pub struct FakeTask;