diff --git a/Cargo.toml b/Cargo.toml index 593a73af98..50b686ce00 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -67,7 +67,7 @@ default = [ "bevy_sprite", "bevy_text", "bevy_ui", - "multi-threaded", + "multi_threaded", "png", "hdr", "vorbis", @@ -252,7 +252,7 @@ symphonia-wav = ["bevy_internal/symphonia-wav"] serialize = ["bevy_internal/serialize"] # Enables multithreaded parallelism in the engine. Disabling it forces all engine tasks to run on a single thread. -multi-threaded = ["bevy_internal/multi-threaded"] +multi_threaded = ["bevy_internal/multi_threaded"] # Use async-io's implementation of block_on instead of futures-lite's implementation. This is preferred if your application uses async-io. async-io = ["bevy_internal/async-io"] diff --git a/benches/Cargo.toml b/benches/Cargo.toml index 417b3a225d..3df074a75c 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -11,7 +11,7 @@ rand = "0.8" rand_chacha = "0.3" criterion = { version = "0.3", features = ["html_reports"] } bevy_app = { path = "../crates/bevy_app" } -bevy_ecs = { path = "../crates/bevy_ecs", features = ["multi-threaded"] } +bevy_ecs = { path = "../crates/bevy_ecs", features = ["multi_threaded"] } bevy_reflect = { path = "../crates/bevy_reflect" } bevy_tasks = { path = "../crates/bevy_tasks" } bevy_utils = { path = "../crates/bevy_utils" } diff --git a/crates/bevy_asset/Cargo.toml b/crates/bevy_asset/Cargo.toml index 6d5e3f5fcd..c0ce99bacd 100644 --- a/crates/bevy_asset/Cargo.toml +++ b/crates/bevy_asset/Cargo.toml @@ -13,7 +13,7 @@ keywords = ["bevy"] [features] file_watcher = ["notify-debouncer-full", "watch"] embedded_watcher = ["file_watcher"] -multi-threaded = ["bevy_tasks/multi-threaded"] +multi_threaded = ["bevy_tasks/multi_threaded"] asset_processor = [] watch = [] trace = [] diff --git a/crates/bevy_asset/src/io/file/mod.rs b/crates/bevy_asset/src/io/file/mod.rs index 19a9ffb0cd..3bbc5074fb 100644 --- a/crates/bevy_asset/src/io/file/mod.rs +++ b/crates/bevy_asset/src/io/file/mod.rs @@ -1,9 +1,9 @@ #[cfg(feature = "file_watcher")] mod file_watcher; -#[cfg(feature = "multi-threaded")] +#[cfg(feature = "multi_threaded")] mod file_asset; -#[cfg(not(feature = "multi-threaded"))] +#[cfg(not(feature = "multi_threaded"))] mod sync_file_asset; use bevy_utils::tracing::error; diff --git a/crates/bevy_asset/src/lib.rs b/crates/bevy_asset/src/lib.rs index 4b3be75ecd..3b56b9cd55 100644 --- a/crates/bevy_asset/src/lib.rs +++ b/crates/bevy_asset/src/lib.rs @@ -62,11 +62,11 @@ use bevy_reflect::{FromReflect, GetTypeRegistration, Reflect, TypePath}; use bevy_utils::{tracing::error, HashSet}; use std::{any::TypeId, sync::Arc}; -#[cfg(all(feature = "file_watcher", not(feature = "multi-threaded")))] +#[cfg(all(feature = "file_watcher", not(feature = "multi_threaded")))] compile_error!( "The \"file_watcher\" feature for hot reloading requires the \ - \"multi-threaded\" feature to be functional.\n\ - Consider either disabling the \"file_watcher\" feature or enabling \"multi-threaded\"" + \"multi_threaded\" feature to be functional.\n\ + Consider either disabling the \"file_watcher\" feature or enabling \"multi_threaded\"" ); /// Provides "asset" loading and processing functionality. An [`Asset`] is a "runtime value" that is loaded from an [`AssetSource`], @@ -659,8 +659,8 @@ mod tests { #[test] fn load_dependencies() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded - #[cfg(not(feature = "multi-threaded"))] - panic!("This test requires the \"multi-threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi-threaded"); + #[cfg(not(feature = "multi_threaded"))] + panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); let dir = Dir::default(); @@ -980,8 +980,8 @@ mod tests { #[test] fn failure_load_states() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded - #[cfg(not(feature = "multi-threaded"))] - panic!("This test requires the \"multi-threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi-threaded"); + #[cfg(not(feature = "multi_threaded"))] + panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); let dir = Dir::default(); @@ -1145,8 +1145,8 @@ mod tests { #[test] fn manual_asset_management() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded - #[cfg(not(feature = "multi-threaded"))] - panic!("This test requires the \"multi-threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi-threaded"); + #[cfg(not(feature = "multi_threaded"))] + panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); let dir = Dir::default(); let dep_path = "dep.cool.ron"; @@ -1246,8 +1246,8 @@ mod tests { #[test] fn load_folder() { // The particular usage of GatedReader in this test will cause deadlocking if running single-threaded - #[cfg(not(feature = "multi-threaded"))] - panic!("This test requires the \"multi-threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi-threaded"); + #[cfg(not(feature = "multi_threaded"))] + panic!("This test requires the \"multi_threaded\" feature, otherwise it will deadlock.\ncargo test --package bevy_asset --features multi_threaded"); let dir = Dir::default(); diff --git a/crates/bevy_asset/src/processor/mod.rs b/crates/bevy_asset/src/processor/mod.rs index 31452a0f85..bd33f9bb15 100644 --- a/crates/bevy_asset/src/processor/mod.rs +++ b/crates/bevy_asset/src/processor/mod.rs @@ -152,9 +152,9 @@ impl AssetProcessor { /// Starts the processor in a background thread. pub fn start(_processor: Res) { - #[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))] + #[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))] error!("Cannot run AssetProcessor in single threaded mode (or WASM) yet."); - #[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] + #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] { let processor = _processor.clone(); std::thread::spawn(move || { @@ -171,7 +171,7 @@ impl AssetProcessor { /// * Scan the unprocessed [`AssetReader`] and remove any final processed assets that are invalid or no longer exist. /// * For each asset in the unprocessed [`AssetReader`], kick off a new "process job", which will process the asset /// (if the latest version of the asset has not been processed). - #[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] + #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] pub fn process_assets(&self) { let start_time = std::time::Instant::now(); debug!("Processing Assets"); @@ -322,9 +322,9 @@ impl AssetProcessor { "Folder {} was added. Attempting to re-process", AssetPath::from_path(&path).with_source(source.id()) ); - #[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))] + #[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))] error!("AddFolder event cannot be handled in single threaded mode (or WASM) yet."); - #[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] + #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] IoTaskPool::get().scope(|scope| { scope.spawn(async move { self.process_assets_internal(scope, source, path) @@ -439,7 +439,7 @@ impl AssetProcessor { } #[allow(unused)] - #[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] + #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] async fn process_assets_internal<'scope>( &'scope self, scope: &'scope bevy_tasks::Scope<'scope, '_, ()>, diff --git a/crates/bevy_ecs/Cargo.toml b/crates/bevy_ecs/Cargo.toml index 62a7fce655..3b7c1640a3 100644 --- a/crates/bevy_ecs/Cargo.toml +++ b/crates/bevy_ecs/Cargo.toml @@ -11,7 +11,7 @@ categories = ["game-engines", "data-structures"] [features] trace = [] -multi-threaded = ["bevy_tasks/multi-threaded", "arrayvec"] +multi_threaded = ["bevy_tasks/multi_threaded", "arrayvec"] bevy_debug_stepping = [] default = ["bevy_reflect"] diff --git a/crates/bevy_ecs/src/event.rs b/crates/bevy_ecs/src/event.rs index d4fada1139..30835e62dd 100644 --- a/crates/bevy_ecs/src/event.rs +++ b/crates/bevy_ecs/src/event.rs @@ -928,12 +928,12 @@ impl<'a, E: Event> EventParIter<'a, E> { /// /// [`ComputeTaskPool`]: bevy_tasks::ComputeTaskPool pub fn for_each_with_id) + Send + Sync + Clone>(self, func: FN) { - #[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))] + #[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))] { self.into_iter().for_each(|(e, i)| func(e, i)); } - #[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] + #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] { let pool = bevy_tasks::ComputeTaskPool::get(); let thread_count = pool.thread_num(); diff --git a/crates/bevy_ecs/src/query/par_iter.rs b/crates/bevy_ecs/src/query/par_iter.rs index f433c31014..7889228ba7 100644 --- a/crates/bevy_ecs/src/query/par_iter.rs +++ b/crates/bevy_ecs/src/query/par_iter.rs @@ -78,7 +78,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryParIter<'w, 's, D, F> { func(&mut init, item); init }; - #[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))] + #[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))] { let init = init(); // SAFETY: @@ -93,7 +93,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryParIter<'w, 's, D, F> { .fold(init, func); } } - #[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] + #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] { let thread_count = bevy_tasks::ComputeTaskPool::get().thread_num(); if thread_count <= 1 { @@ -122,7 +122,7 @@ impl<'w, 's, D: QueryData, F: QueryFilter> QueryParIter<'w, 's, D, F> { } } - #[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] + #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] fn get_batch_size(&self, thread_count: usize) -> usize { let max_items = || { let id_iter = self.state.matched_storage_ids.iter(); diff --git a/crates/bevy_ecs/src/query/state.rs b/crates/bevy_ecs/src/query/state.rs index 5e52178837..6cbae544f9 100644 --- a/crates/bevy_ecs/src/query/state.rs +++ b/crates/bevy_ecs/src/query/state.rs @@ -1393,7 +1393,7 @@ impl QueryState { /// with a mismatched [`WorldId`] is unsound. /// /// [`ComputeTaskPool`]: bevy_tasks::ComputeTaskPool - #[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] + #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] pub(crate) unsafe fn par_fold_init_unchecked_manual<'w, T, FN, INIT>( &self, init_accum: INIT, diff --git a/crates/bevy_ecs/src/schedule/executor/mod.rs b/crates/bevy_ecs/src/schedule/executor/mod.rs index 3bf2f7edeb..3d76fdb184 100644 --- a/crates/bevy_ecs/src/schedule/executor/mod.rs +++ b/crates/bevy_ecs/src/schedule/executor/mod.rs @@ -38,18 +38,18 @@ pub enum ExecutorKind { /// /// Useful if you're dealing with a single-threaded environment, saving your threads for /// other things, or just trying minimize overhead. - #[cfg_attr(any(target_arch = "wasm32", not(feature = "multi-threaded")), default)] + #[cfg_attr(any(target_arch = "wasm32", not(feature = "multi_threaded")), default)] SingleThreaded, /// Like [`SingleThreaded`](ExecutorKind::SingleThreaded) but calls [`apply_deferred`](crate::system::System::apply_deferred) /// immediately after running each system. Simple, /// Runs the schedule using a thread pool. Non-conflicting systems can run in parallel. - #[cfg_attr(all(not(target_arch = "wasm32"), feature = "multi-threaded"), default)] + #[cfg_attr(all(not(target_arch = "wasm32"), feature = "multi_threaded"), default)] MultiThreaded, } /// Holds systems and conditions of a [`Schedule`](super::Schedule) sorted in topological order -/// (along with dependency information for multi-threaded execution). +/// (along with dependency information for `multi_threaded` execution). /// /// Since the arrays are sorted in the same order, elements are referenced by their index. /// [`FixedBitSet`] is used as a smaller, more efficient substitute of `HashSet`. diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index fa9a190580..39606d998e 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -317,7 +317,7 @@ impl<'scope, 'env: 'scope, 'sys> Context<'scope, 'env, 'sys> { } impl MultiThreadedExecutor { - /// Creates a new multi-threaded executor for use with a [`Schedule`]. + /// Creates a new `multi_threaded` executor for use with a [`Schedule`]. /// /// [`Schedule`]: crate::schedule::Schedule pub fn new() -> Self { diff --git a/crates/bevy_ecs/src/schedule/schedule.rs b/crates/bevy_ecs/src/schedule/schedule.rs index 89a65ecd37..c9dc06438f 100644 --- a/crates/bevy_ecs/src/schedule/schedule.rs +++ b/crates/bevy_ecs/src/schedule/schedule.rs @@ -1419,7 +1419,7 @@ impl ScheduleGraph { let hg_node_count = self.hierarchy.graph.node_count(); // get the number of dependencies and the immediate dependents of each system - // (needed by multi-threaded executor to run systems in the correct order) + // (needed by multi_threaded executor to run systems in the correct order) let mut system_dependencies = Vec::with_capacity(sys_count); let mut system_dependents = Vec::with_capacity(sys_count); for &sys_id in &dg_system_ids { diff --git a/crates/bevy_internal/Cargo.toml b/crates/bevy_internal/Cargo.toml index 36b63ff193..0e4713bba9 100644 --- a/crates/bevy_internal/Cargo.toml +++ b/crates/bevy_internal/Cargo.toml @@ -77,11 +77,11 @@ serialize = [ "bevy_ui?/serialize", "bevy_color?/serialize", ] -multi-threaded = [ - "bevy_asset?/multi-threaded", - "bevy_ecs/multi-threaded", - "bevy_render?/multi-threaded", - "bevy_tasks/multi-threaded", +multi_threaded = [ + "bevy_asset?/multi_threaded", + "bevy_ecs/multi_threaded", + "bevy_render?/multi_threaded", + "bevy_tasks/multi_threaded", ] async-io = ["bevy_tasks/async-io"] diff --git a/crates/bevy_internal/src/default_plugins.rs b/crates/bevy_internal/src/default_plugins.rs index acfa89d0b6..10d595df6e 100644 --- a/crates/bevy_internal/src/default_plugins.rs +++ b/crates/bevy_internal/src/default_plugins.rs @@ -79,7 +79,7 @@ impl PluginGroup for DefaultPlugins { // compressed texture formats .add(bevy_render::texture::ImagePlugin::default()); - #[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] + #[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] { group = group.add(bevy_render::pipelined_rendering::PipelinedRenderingPlugin); } diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 82d16c9337..7b0511dbd2 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -18,7 +18,7 @@ bmp = ["image/bmp"] webp = ["image/webp"] dds = ["ddsfile"] pnm = ["image/pnm"] -multi-threaded = ["bevy_tasks/multi-threaded"] +multi_threaded = ["bevy_tasks/multi_threaded"] shader_format_glsl = ["naga/glsl-in", "naga/wgsl-out", "naga_oil/glsl"] shader_format_spirv = ["wgpu/spirv", "naga/spv-in", "naga/spv-out"] diff --git a/crates/bevy_render/src/lib.rs b/crates/bevy_render/src/lib.rs index 108adbabb9..dea5f7bb7d 100644 --- a/crates/bevy_render/src/lib.rs +++ b/crates/bevy_render/src/lib.rs @@ -96,7 +96,7 @@ use std::{ pub struct RenderPlugin { pub render_creation: RenderCreation, /// If `true`, disables asynchronous pipeline compilation. - /// This has no effect on macOS, Wasm, iOS, or without the `multi-threaded` feature. + /// This has no effect on macOS, Wasm, iOS, or without the `multi_threaded` feature. pub synchronous_pipeline_compilation: bool, } diff --git a/crates/bevy_render/src/render_resource/pipeline_cache.rs b/crates/bevy_render/src/render_resource/pipeline_cache.rs index 377e24ce7e..678be9b0bd 100644 --- a/crates/bevy_render/src/render_resource/pipeline_cache.rs +++ b/crates/bevy_render/src/render_resource/pipeline_cache.rs @@ -982,7 +982,7 @@ impl PipelineCache { #[cfg(all( not(target_arch = "wasm32"), not(target_os = "macos"), - feature = "multi-threaded" + feature = "multi_threaded" ))] fn create_pipeline_task( task: impl Future> + Send + 'static, @@ -1001,7 +1001,7 @@ fn create_pipeline_task( #[cfg(any( target_arch = "wasm32", target_os = "macos", - not(feature = "multi-threaded") + not(feature = "multi_threaded") ))] fn create_pipeline_task( task: impl Future> + Send + 'static, diff --git a/crates/bevy_tasks/Cargo.toml b/crates/bevy_tasks/Cargo.toml index eb9cc232e5..c7db7eeae7 100644 --- a/crates/bevy_tasks/Cargo.toml +++ b/crates/bevy_tasks/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" keywords = ["bevy"] [features] -multi-threaded = ["dep:async-channel", "dep:concurrent-queue"] +multi_threaded = ["dep:async-channel", "dep:concurrent-queue"] [dependencies] futures-lite = "2.0.1" diff --git a/crates/bevy_tasks/src/lib.rs b/crates/bevy_tasks/src/lib.rs index 34011532d6..17cfb348ef 100644 --- a/crates/bevy_tasks/src/lib.rs +++ b/crates/bevy_tasks/src/lib.rs @@ -11,14 +11,14 @@ pub use slice::{ParallelSlice, ParallelSliceMut}; mod task; pub use task::Task; -#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] +#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] mod task_pool; -#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] +#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] 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; -#[cfg(any(target_arch = "wasm32", not(feature = "multi-threaded")))] +#[cfg(any(target_arch = "wasm32", not(feature = "multi_threaded")))] pub use single_threaded_task_pool::{FakeTask, Scope, TaskPool, TaskPoolBuilder, ThreadExecutor}; mod usages; @@ -26,9 +26,9 @@ mod usages; pub use usages::tick_global_task_pools_on_main_thread; pub use usages::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool}; -#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] +#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] mod thread_executor; -#[cfg(all(not(target_arch = "wasm32"), feature = "multi-threaded"))] +#[cfg(all(not(target_arch = "wasm32"), feature = "multi_threaded"))] pub use thread_executor::{ThreadExecutor, ThreadExecutorTicker}; #[cfg(feature = "async-io")] diff --git a/docs/cargo_features.md b/docs/cargo_features.md index a4ea90d371..8a154ca433 100644 --- a/docs/cargo_features.md +++ b/docs/cargo_features.md @@ -31,7 +31,7 @@ The default feature set enables most of the expected features of a game engine, |default_font|Include a default font, containing only ASCII characters, at the cost of a 20kB binary size increase| |hdr|HDR image format support| |ktx2|KTX2 compressed texture support| -|multi-threaded|Enables multithreaded parallelism in the engine. Disabling it forces all engine tasks to run on a single thread.| +|multi_threaded|Enables multithreaded parallelism in the engine. Disabling it forces all engine tasks to run on a single thread.| |png|PNG image format support| |sysinfo_plugin|Enables system information diagnostic plugin| |tonemapping_luts|Include tonemapping Look Up Tables KTX2 files. If everything is pink, you need to enable this feature or change the `Tonemapping` method on your `Camera2dBundle` or `Camera3dBundle`.|