Skip to content

Commit a2ab7dd

Browse files
committed
refactor(utils): move SyncCell and SyncUnsafeCell to bevy_platform
1 parent 1791494 commit a2ab7dd

File tree

16 files changed

+30
-15
lines changed

16 files changed

+30
-15
lines changed

crates/bevy_ecs/src/component.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ use thiserror::Error;
481481
/// ```
482482
/// # use std::cell::RefCell;
483483
/// # use bevy_ecs::component::Component;
484-
/// use bevy_utils::synccell::SyncCell;
484+
/// use bevy_platform::cell::SyncCell;
485485
///
486486
/// // This will compile.
487487
/// #[derive(Component)]
@@ -490,7 +490,7 @@ use thiserror::Error;
490490
/// }
491491
/// ```
492492
///
493-
/// [`SyncCell`]: bevy_utils::synccell::SyncCell
493+
/// [`SyncCell`]: bevy_platform::cell::SyncCell
494494
/// [`Exclusive`]: https://doc.rust-lang.org/nightly/std/sync/struct.Exclusive.html
495495
#[diagnostic::on_unimplemented(
496496
message = "`{Self}` is not a `Component`",

crates/bevy_ecs/src/resource.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub use bevy_ecs_macros::Resource;
5454
/// ```
5555
/// # use std::cell::RefCell;
5656
/// # use bevy_ecs::resource::Resource;
57-
/// use bevy_utils::synccell::SyncCell;
57+
/// use bevy_platform::cell::SyncCell;
5858
///
5959
/// #[derive(Resource)]
6060
/// struct ActuallySync {
@@ -66,7 +66,7 @@ pub use bevy_ecs_macros::Resource;
6666
/// [`World`]: crate::world::World
6767
/// [`Res`]: crate::system::Res
6868
/// [`ResMut`]: crate::system::ResMut
69-
/// [`SyncCell`]: bevy_utils::synccell::SyncCell
69+
/// [`SyncCell`]: bevy_platform::cell::SyncCell
7070
#[diagnostic::on_unimplemented(
7171
message = "`{Self}` is not a `Resource`",
7272
label = "invalid `Resource`",

crates/bevy_ecs/src/schedule/executor/multi_threaded.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use alloc::{boxed::Box, vec::Vec};
2+
use bevy_platform::cell::SyncUnsafeCell;
23
use bevy_platform::sync::Arc;
34
use bevy_tasks::{ComputeTaskPool, Scope, TaskPool, ThreadExecutor};
4-
use bevy_utils::syncunsafecell::SyncUnsafeCell;
55
use concurrent_queue::ConcurrentQueue;
66
use core::{any::Any, panic::AssertUnwindSafe};
77
use fixedbitset::FixedBitSet;

crates/bevy_ecs/src/system/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use alloc::{boxed::Box, vec::Vec};
2-
use bevy_utils::synccell::SyncCell;
2+
use bevy_platform::cell::SyncCell;
33
use variadics_please::all_tuples;
44

55
use crate::{

crates/bevy_ecs/src/system/exclusive_system_param.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::{
44
system::{Local, SystemMeta, SystemParam, SystemState},
55
world::World,
66
};
7-
use bevy_utils::synccell::SyncCell;
7+
use bevy_platform::cell::SyncCell;
88
use core::marker::PhantomData;
99
use variadics_please::all_tuples;
1010

crates/bevy_ecs/src/system/system_param.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use alloc::{
2323
vec::Vec,
2424
};
2525
pub use bevy_ecs_macros::SystemParam;
26+
use bevy_platform::cell::SyncCell;
2627
use bevy_ptr::UnsafeCellDeref;
27-
use bevy_utils::synccell::SyncCell;
2828
use core::{
2929
any::Any,
3030
fmt::{Debug, Display},

crates/bevy_gilrs/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ mod gilrs_system;
1515
mod rumble;
1616

1717
#[cfg(not(target_arch = "wasm32"))]
18-
use bevy_utils::synccell::SyncCell;
18+
use bevy_platform::cell::SyncCell;
1919

2020
#[cfg(target_arch = "wasm32")]
2121
use core::cell::RefCell;

crates/bevy_gilrs/src/rumble.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
use crate::{Gilrs, GilrsGamepads};
33
use bevy_ecs::prelude::{EventReader, Res, ResMut, Resource};
44
use bevy_input::gamepad::{GamepadRumbleIntensity, GamepadRumbleRequest};
5+
use bevy_platform::cell::SyncCell;
56
use bevy_platform::collections::HashMap;
67
use bevy_time::{Real, Time};
7-
use bevy_utils::synccell::SyncCell;
88
use core::time::Duration;
99
use gilrs::{
1010
ff::{self, BaseEffect, BaseEffectType, Repeat, Replay},

crates/bevy_log/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ trace_tracy_memory = ["dep:tracy-client"]
1616
# bevy
1717
bevy_app = { path = "../bevy_app", version = "0.16.0-dev" }
1818
bevy_utils = { path = "../bevy_utils", version = "0.16.0-dev" }
19+
bevy_platform = { path = "../bevy_platform", version = "0.16.0-dev" }
1920
bevy_ecs = { path = "../bevy_ecs", version = "0.16.0-dev" }
2021

2122
# other

crates/bevy_log/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ use tracing_subscriber::{
6464
#[cfg(feature = "tracing-chrome")]
6565
use {
6666
bevy_ecs::resource::Resource,
67-
bevy_utils::synccell::SyncCell,
67+
bevy_platform::cell::SyncCell,
6868
tracing_subscriber::fmt::{format::DefaultFields, FormattedFields},
6969
};
7070

crates/bevy_platform/src/cell/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//! Provides cell primitives.
2+
//!
3+
//! This is a drop-in replacement for `std::cell::SyncCell`/`std::cell::SyncUnsafeCell`.
4+
5+
mod sync_cell;
6+
mod sync_unsafe_cell;
7+
8+
pub use sync_cell::SyncCell;
9+
pub use sync_unsafe_cell::SyncUnsafeCell;

crates/bevy_utils/src/syncunsafecell.rs renamed to crates/bevy_platform/src/cell/sync_unsafe_cell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl<T> SyncUnsafeCell<[T]> {
9494
/// # Examples
9595
///
9696
/// ```
97-
/// # use bevy_utils::syncunsafecell::SyncUnsafeCell;
97+
/// # use bevy_platform::cell::SyncUnsafeCell;
9898
///
9999
/// let slice: &mut [i32] = &mut [1, 2, 3];
100100
/// let cell_slice: &SyncUnsafeCell<[i32]> = SyncUnsafeCell::from_mut(slice);

crates/bevy_platform/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ cfg::alloc! {
1919
pub mod collections;
2020
}
2121

22+
pub mod cell;
2223
pub mod cfg;
2324
pub mod hash;
2425
pub mod sync;

crates/bevy_utils/src/lib.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ pub mod prelude {
2222
pub use crate::default;
2323
}
2424

25-
pub mod synccell;
26-
pub mod syncunsafecell;
27-
2825
mod default;
2926
mod once;
3027
#[cfg(feature = "std")]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: SyncCell and SyncUnsafeCell moved to bevy_platform
3+
pull_requests: [19305]
4+
---
5+
6+
`bevy_utils::synccell::SyncCell` is now `bevy_platform::cell::SyncCell`
7+
`bevy_utils::syncunsafecell::SyncUnsafeCell` is now `bevy_platform::cell::SyncUnsafeCell`

0 commit comments

Comments
 (0)