diff --git a/crates/bevy_ecs/src/component.rs b/crates/bevy_ecs/src/component.rs index e7c14d1c3e..80e60a8860 100644 --- a/crates/bevy_ecs/src/component.rs +++ b/crates/bevy_ecs/src/component.rs @@ -481,7 +481,7 @@ use thiserror::Error; /// ``` /// # use std::cell::RefCell; /// # use bevy_ecs::component::Component; -/// use bevy_utils::synccell::SyncCell; +/// use bevy_platform::cell::SyncCell; /// /// // This will compile. /// #[derive(Component)] @@ -490,7 +490,7 @@ use thiserror::Error; /// } /// ``` /// -/// [`SyncCell`]: bevy_utils::synccell::SyncCell +/// [`SyncCell`]: bevy_platform::cell::SyncCell /// [`Exclusive`]: https://doc.rust-lang.org/nightly/std/sync/struct.Exclusive.html #[diagnostic::on_unimplemented( message = "`{Self}` is not a `Component`", diff --git a/crates/bevy_ecs/src/resource.rs b/crates/bevy_ecs/src/resource.rs index c3f7805631..7da4f31113 100644 --- a/crates/bevy_ecs/src/resource.rs +++ b/crates/bevy_ecs/src/resource.rs @@ -54,7 +54,7 @@ pub use bevy_ecs_macros::Resource; /// ``` /// # use std::cell::RefCell; /// # use bevy_ecs::resource::Resource; -/// use bevy_utils::synccell::SyncCell; +/// use bevy_platform::cell::SyncCell; /// /// #[derive(Resource)] /// struct ActuallySync { @@ -66,7 +66,7 @@ pub use bevy_ecs_macros::Resource; /// [`World`]: crate::world::World /// [`Res`]: crate::system::Res /// [`ResMut`]: crate::system::ResMut -/// [`SyncCell`]: bevy_utils::synccell::SyncCell +/// [`SyncCell`]: bevy_platform::cell::SyncCell #[diagnostic::on_unimplemented( message = "`{Self}` is not a `Resource`", label = "invalid `Resource`", diff --git a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs index 763504eaec..a1363270aa 100644 --- a/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs +++ b/crates/bevy_ecs/src/schedule/executor/multi_threaded.rs @@ -1,7 +1,7 @@ use alloc::{boxed::Box, vec::Vec}; +use bevy_platform::cell::SyncUnsafeCell; use bevy_platform::sync::Arc; use bevy_tasks::{ComputeTaskPool, Scope, TaskPool, ThreadExecutor}; -use bevy_utils::syncunsafecell::SyncUnsafeCell; use concurrent_queue::ConcurrentQueue; use core::{any::Any, panic::AssertUnwindSafe}; use fixedbitset::FixedBitSet; diff --git a/crates/bevy_ecs/src/system/builder.rs b/crates/bevy_ecs/src/system/builder.rs index 441d4d42fc..d1cb3421c2 100644 --- a/crates/bevy_ecs/src/system/builder.rs +++ b/crates/bevy_ecs/src/system/builder.rs @@ -1,5 +1,5 @@ use alloc::{boxed::Box, vec::Vec}; -use bevy_utils::synccell::SyncCell; +use bevy_platform::cell::SyncCell; use variadics_please::all_tuples; use crate::{ diff --git a/crates/bevy_ecs/src/system/exclusive_system_param.rs b/crates/bevy_ecs/src/system/exclusive_system_param.rs index f271e32e2f..f87182ab1f 100644 --- a/crates/bevy_ecs/src/system/exclusive_system_param.rs +++ b/crates/bevy_ecs/src/system/exclusive_system_param.rs @@ -4,7 +4,7 @@ use crate::{ system::{Local, SystemMeta, SystemParam, SystemState}, world::World, }; -use bevy_utils::synccell::SyncCell; +use bevy_platform::cell::SyncCell; use core::marker::PhantomData; use variadics_please::all_tuples; diff --git a/crates/bevy_ecs/src/system/system_param.rs b/crates/bevy_ecs/src/system/system_param.rs index f2774116f0..efa888cf14 100644 --- a/crates/bevy_ecs/src/system/system_param.rs +++ b/crates/bevy_ecs/src/system/system_param.rs @@ -23,8 +23,8 @@ use alloc::{ vec::Vec, }; pub use bevy_ecs_macros::SystemParam; +use bevy_platform::cell::SyncCell; use bevy_ptr::UnsafeCellDeref; -use bevy_utils::synccell::SyncCell; use core::{ any::Any, fmt::{Debug, Display}, diff --git a/crates/bevy_gilrs/src/lib.rs b/crates/bevy_gilrs/src/lib.rs index b9f1d9d286..66cc0e3328 100644 --- a/crates/bevy_gilrs/src/lib.rs +++ b/crates/bevy_gilrs/src/lib.rs @@ -15,7 +15,7 @@ mod gilrs_system; mod rumble; #[cfg(not(target_arch = "wasm32"))] -use bevy_utils::synccell::SyncCell; +use bevy_platform::cell::SyncCell; #[cfg(target_arch = "wasm32")] use core::cell::RefCell; diff --git a/crates/bevy_gilrs/src/rumble.rs b/crates/bevy_gilrs/src/rumble.rs index 8f41a3ca22..b03fa69fe3 100644 --- a/crates/bevy_gilrs/src/rumble.rs +++ b/crates/bevy_gilrs/src/rumble.rs @@ -2,9 +2,9 @@ use crate::{Gilrs, GilrsGamepads}; use bevy_ecs::prelude::{EventReader, Res, ResMut, Resource}; use bevy_input::gamepad::{GamepadRumbleIntensity, GamepadRumbleRequest}; +use bevy_platform::cell::SyncCell; use bevy_platform::collections::HashMap; use bevy_time::{Real, Time}; -use bevy_utils::synccell::SyncCell; use core::time::Duration; use gilrs::{ ff::{self, BaseEffect, BaseEffectType, Repeat, Replay}, diff --git a/crates/bevy_log/Cargo.toml b/crates/bevy_log/Cargo.toml index cc7c53e676..32902a2dda 100644 --- a/crates/bevy_log/Cargo.toml +++ b/crates/bevy_log/Cargo.toml @@ -16,6 +16,7 @@ trace_tracy_memory = ["dep:tracy-client"] # bevy bevy_app = { path = "../bevy_app", version = "0.16.0-dev" } bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev" } +bevy_platform = { path = "../bevy_platform", version = "0.16.0-dev" } bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" } # other diff --git a/crates/bevy_log/src/lib.rs b/crates/bevy_log/src/lib.rs index 6562fef7fa..aa8092c834 100644 --- a/crates/bevy_log/src/lib.rs +++ b/crates/bevy_log/src/lib.rs @@ -64,7 +64,7 @@ use tracing_subscriber::{ #[cfg(feature = "tracing-chrome")] use { bevy_ecs::resource::Resource, - bevy_utils::synccell::SyncCell, + bevy_platform::cell::SyncCell, tracing_subscriber::fmt::{format::DefaultFields, FormattedFields}, }; diff --git a/crates/bevy_platform/src/cell/mod.rs b/crates/bevy_platform/src/cell/mod.rs new file mode 100644 index 0000000000..04f8bf6572 --- /dev/null +++ b/crates/bevy_platform/src/cell/mod.rs @@ -0,0 +1,9 @@ +//! Provides cell primitives. +//! +//! This is a drop-in replacement for `std::cell::SyncCell`/`std::cell::SyncUnsafeCell`. + +mod sync_cell; +mod sync_unsafe_cell; + +pub use sync_cell::SyncCell; +pub use sync_unsafe_cell::SyncUnsafeCell; diff --git a/crates/bevy_utils/src/synccell.rs b/crates/bevy_platform/src/cell/sync_cell.rs similarity index 100% rename from crates/bevy_utils/src/synccell.rs rename to crates/bevy_platform/src/cell/sync_cell.rs diff --git a/crates/bevy_utils/src/syncunsafecell.rs b/crates/bevy_platform/src/cell/sync_unsafe_cell.rs similarity index 98% rename from crates/bevy_utils/src/syncunsafecell.rs rename to crates/bevy_platform/src/cell/sync_unsafe_cell.rs index 104256969d..bb67557ec2 100644 --- a/crates/bevy_utils/src/syncunsafecell.rs +++ b/crates/bevy_platform/src/cell/sync_unsafe_cell.rs @@ -94,7 +94,7 @@ impl SyncUnsafeCell<[T]> { /// # Examples /// /// ``` - /// # use bevy_utils::syncunsafecell::SyncUnsafeCell; + /// # use bevy_platform::cell::SyncUnsafeCell; /// /// let slice: &mut [i32] = &mut [1, 2, 3]; /// let cell_slice: &SyncUnsafeCell<[i32]> = SyncUnsafeCell::from_mut(slice); diff --git a/crates/bevy_platform/src/lib.rs b/crates/bevy_platform/src/lib.rs index 668442f299..d5871defb4 100644 --- a/crates/bevy_platform/src/lib.rs +++ b/crates/bevy_platform/src/lib.rs @@ -19,6 +19,7 @@ cfg::alloc! { pub mod collections; } +pub mod cell; pub mod cfg; pub mod hash; pub mod sync; diff --git a/crates/bevy_utils/src/lib.rs b/crates/bevy_utils/src/lib.rs index 88c4b4e157..164610eb9b 100644 --- a/crates/bevy_utils/src/lib.rs +++ b/crates/bevy_utils/src/lib.rs @@ -46,8 +46,6 @@ pub mod prelude { pub use crate::default; } -pub mod synccell; -pub mod syncunsafecell; #[cfg(feature = "wgpu_wrapper")] mod wgpu_wrapper; diff --git a/release-content/migration-guides/sync_cell_utils.md b/release-content/migration-guides/sync_cell_utils.md new file mode 100644 index 0000000000..7ecc706cc9 --- /dev/null +++ b/release-content/migration-guides/sync_cell_utils.md @@ -0,0 +1,7 @@ +--- +title: SyncCell and SyncUnsafeCell moved to bevy_platform +pull_requests: [19305] +--- + +`bevy_utils::synccell::SyncCell` is now `bevy_platform::cell::SyncCell` +`bevy_utils::syncunsafecell::SyncUnsafeCell` is now `bevy_platform::cell::SyncUnsafeCell`