refactor(utils): move SyncCell and SyncUnsafeCell to bevy_platform (#19305)
# Objective - move SyncCell and SyncUnsafeCell to bevy_platform ## Solution - move SyncCell and SyncUnsafeCell to bevy_platform ## Testing - cargo clippy works
This commit is contained in:
parent
dc6563477d
commit
d4985af7cb
@ -481,7 +481,7 @@ use thiserror::Error;
|
|||||||
/// ```
|
/// ```
|
||||||
/// # use std::cell::RefCell;
|
/// # use std::cell::RefCell;
|
||||||
/// # use bevy_ecs::component::Component;
|
/// # use bevy_ecs::component::Component;
|
||||||
/// use bevy_utils::synccell::SyncCell;
|
/// use bevy_platform::cell::SyncCell;
|
||||||
///
|
///
|
||||||
/// // This will compile.
|
/// // This will compile.
|
||||||
/// #[derive(Component)]
|
/// #[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
|
/// [`Exclusive`]: https://doc.rust-lang.org/nightly/std/sync/struct.Exclusive.html
|
||||||
#[diagnostic::on_unimplemented(
|
#[diagnostic::on_unimplemented(
|
||||||
message = "`{Self}` is not a `Component`",
|
message = "`{Self}` is not a `Component`",
|
||||||
|
@ -54,7 +54,7 @@ pub use bevy_ecs_macros::Resource;
|
|||||||
/// ```
|
/// ```
|
||||||
/// # use std::cell::RefCell;
|
/// # use std::cell::RefCell;
|
||||||
/// # use bevy_ecs::resource::Resource;
|
/// # use bevy_ecs::resource::Resource;
|
||||||
/// use bevy_utils::synccell::SyncCell;
|
/// use bevy_platform::cell::SyncCell;
|
||||||
///
|
///
|
||||||
/// #[derive(Resource)]
|
/// #[derive(Resource)]
|
||||||
/// struct ActuallySync {
|
/// struct ActuallySync {
|
||||||
@ -66,7 +66,7 @@ pub use bevy_ecs_macros::Resource;
|
|||||||
/// [`World`]: crate::world::World
|
/// [`World`]: crate::world::World
|
||||||
/// [`Res`]: crate::system::Res
|
/// [`Res`]: crate::system::Res
|
||||||
/// [`ResMut`]: crate::system::ResMut
|
/// [`ResMut`]: crate::system::ResMut
|
||||||
/// [`SyncCell`]: bevy_utils::synccell::SyncCell
|
/// [`SyncCell`]: bevy_platform::cell::SyncCell
|
||||||
#[diagnostic::on_unimplemented(
|
#[diagnostic::on_unimplemented(
|
||||||
message = "`{Self}` is not a `Resource`",
|
message = "`{Self}` is not a `Resource`",
|
||||||
label = "invalid `Resource`",
|
label = "invalid `Resource`",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use alloc::{boxed::Box, vec::Vec};
|
use alloc::{boxed::Box, vec::Vec};
|
||||||
|
use bevy_platform::cell::SyncUnsafeCell;
|
||||||
use bevy_platform::sync::Arc;
|
use bevy_platform::sync::Arc;
|
||||||
use bevy_tasks::{ComputeTaskPool, Scope, TaskPool, ThreadExecutor};
|
use bevy_tasks::{ComputeTaskPool, Scope, TaskPool, ThreadExecutor};
|
||||||
use bevy_utils::syncunsafecell::SyncUnsafeCell;
|
|
||||||
use concurrent_queue::ConcurrentQueue;
|
use concurrent_queue::ConcurrentQueue;
|
||||||
use core::{any::Any, panic::AssertUnwindSafe};
|
use core::{any::Any, panic::AssertUnwindSafe};
|
||||||
use fixedbitset::FixedBitSet;
|
use fixedbitset::FixedBitSet;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use alloc::{boxed::Box, vec::Vec};
|
use alloc::{boxed::Box, vec::Vec};
|
||||||
use bevy_utils::synccell::SyncCell;
|
use bevy_platform::cell::SyncCell;
|
||||||
use variadics_please::all_tuples;
|
use variadics_please::all_tuples;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
|
@ -4,7 +4,7 @@ use crate::{
|
|||||||
system::{Local, SystemMeta, SystemParam, SystemState},
|
system::{Local, SystemMeta, SystemParam, SystemState},
|
||||||
world::World,
|
world::World,
|
||||||
};
|
};
|
||||||
use bevy_utils::synccell::SyncCell;
|
use bevy_platform::cell::SyncCell;
|
||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use variadics_please::all_tuples;
|
use variadics_please::all_tuples;
|
||||||
|
|
||||||
|
@ -23,8 +23,8 @@ use alloc::{
|
|||||||
vec::Vec,
|
vec::Vec,
|
||||||
};
|
};
|
||||||
pub use bevy_ecs_macros::SystemParam;
|
pub use bevy_ecs_macros::SystemParam;
|
||||||
|
use bevy_platform::cell::SyncCell;
|
||||||
use bevy_ptr::UnsafeCellDeref;
|
use bevy_ptr::UnsafeCellDeref;
|
||||||
use bevy_utils::synccell::SyncCell;
|
|
||||||
use core::{
|
use core::{
|
||||||
any::Any,
|
any::Any,
|
||||||
fmt::{Debug, Display},
|
fmt::{Debug, Display},
|
||||||
|
@ -15,7 +15,7 @@ mod gilrs_system;
|
|||||||
mod rumble;
|
mod rumble;
|
||||||
|
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
use bevy_utils::synccell::SyncCell;
|
use bevy_platform::cell::SyncCell;
|
||||||
|
|
||||||
#[cfg(target_arch = "wasm32")]
|
#[cfg(target_arch = "wasm32")]
|
||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
use crate::{Gilrs, GilrsGamepads};
|
use crate::{Gilrs, GilrsGamepads};
|
||||||
use bevy_ecs::prelude::{EventReader, Res, ResMut, Resource};
|
use bevy_ecs::prelude::{EventReader, Res, ResMut, Resource};
|
||||||
use bevy_input::gamepad::{GamepadRumbleIntensity, GamepadRumbleRequest};
|
use bevy_input::gamepad::{GamepadRumbleIntensity, GamepadRumbleRequest};
|
||||||
|
use bevy_platform::cell::SyncCell;
|
||||||
use bevy_platform::collections::HashMap;
|
use bevy_platform::collections::HashMap;
|
||||||
use bevy_time::{Real, Time};
|
use bevy_time::{Real, Time};
|
||||||
use bevy_utils::synccell::SyncCell;
|
|
||||||
use core::time::Duration;
|
use core::time::Duration;
|
||||||
use gilrs::{
|
use gilrs::{
|
||||||
ff::{self, BaseEffect, BaseEffectType, Repeat, Replay},
|
ff::{self, BaseEffect, BaseEffectType, Repeat, Replay},
|
||||||
|
@ -16,6 +16,7 @@ trace_tracy_memory = ["dep:tracy-client"]
|
|||||||
# bevy
|
# bevy
|
||||||
bevy_app = { path = "../bevy_app", version = "0.16.0-dev" }
|
bevy_app = { path = "../bevy_app", version = "0.16.0-dev" }
|
||||||
bevy_utils = { path = "../bevy_utils", 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" }
|
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" }
|
||||||
|
|
||||||
# other
|
# other
|
||||||
|
@ -64,7 +64,7 @@ use tracing_subscriber::{
|
|||||||
#[cfg(feature = "tracing-chrome")]
|
#[cfg(feature = "tracing-chrome")]
|
||||||
use {
|
use {
|
||||||
bevy_ecs::resource::Resource,
|
bevy_ecs::resource::Resource,
|
||||||
bevy_utils::synccell::SyncCell,
|
bevy_platform::cell::SyncCell,
|
||||||
tracing_subscriber::fmt::{format::DefaultFields, FormattedFields},
|
tracing_subscriber::fmt::{format::DefaultFields, FormattedFields},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
9
crates/bevy_platform/src/cell/mod.rs
Normal file
9
crates/bevy_platform/src/cell/mod.rs
Normal file
@ -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;
|
@ -94,7 +94,7 @@ impl<T> SyncUnsafeCell<[T]> {
|
|||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// # use bevy_utils::syncunsafecell::SyncUnsafeCell;
|
/// # use bevy_platform::cell::SyncUnsafeCell;
|
||||||
///
|
///
|
||||||
/// let slice: &mut [i32] = &mut [1, 2, 3];
|
/// let slice: &mut [i32] = &mut [1, 2, 3];
|
||||||
/// let cell_slice: &SyncUnsafeCell<[i32]> = SyncUnsafeCell::from_mut(slice);
|
/// let cell_slice: &SyncUnsafeCell<[i32]> = SyncUnsafeCell::from_mut(slice);
|
@ -19,6 +19,7 @@ cfg::alloc! {
|
|||||||
pub mod collections;
|
pub mod collections;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub mod cell;
|
||||||
pub mod cfg;
|
pub mod cfg;
|
||||||
pub mod hash;
|
pub mod hash;
|
||||||
pub mod sync;
|
pub mod sync;
|
||||||
|
@ -46,8 +46,6 @@ pub mod prelude {
|
|||||||
pub use crate::default;
|
pub use crate::default;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod synccell;
|
|
||||||
pub mod syncunsafecell;
|
|
||||||
#[cfg(feature = "wgpu_wrapper")]
|
#[cfg(feature = "wgpu_wrapper")]
|
||||||
mod wgpu_wrapper;
|
mod wgpu_wrapper;
|
||||||
|
|
||||||
|
7
release-content/migration-guides/sync_cell_utils.md
Normal file
7
release-content/migration-guides/sync_cell_utils.md
Normal file
@ -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`
|
Loading…
Reference in New Issue
Block a user