Skip to content

Commit 3996492

Browse files
bushrat011899NthTensor
authored andcommitted
Clean bevy_tasks features
1 parent f96eaa4 commit 3996492

File tree

17 files changed

+268
-220
lines changed

17 files changed

+268
-220
lines changed

crates/bevy_app/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,13 @@ std = [
4747
"bevy_ecs/std",
4848
"dep:ctrlc",
4949
"downcast-rs/std",
50-
"bevy_tasks/std",
50+
"bevy_utils/std",
5151
"bevy_platform/std",
5252
]
5353

5454
## `critical-section` provides the building blocks for synchronization primitives
5555
## on all platforms, including `no_std`.
5656
critical-section = [
57-
"bevy_tasks/critical-section",
5857
"bevy_ecs/critical-section",
5958
"bevy_platform/critical-section",
6059
"bevy_reflect?/critical-section",
@@ -64,7 +63,6 @@ critical-section = [
6463
## Note this is currently only applicable on `wasm32` architectures.
6564
web = [
6665
"bevy_platform/web",
67-
"bevy_tasks/web",
6866
"bevy_reflect?/web",
6967
"dep:wasm-bindgen",
7068
"dep:web-sys",

crates/bevy_asset/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ uuid = { version = "1.13.1", default-features = false, features = ["js"] }
8181
bevy_app = { path = "../bevy_app", version = "0.17.0-dev", default-features = false, features = [
8282
"web",
8383
] }
84-
bevy_tasks = { path = "../bevy_tasks", version = "0.17.0-dev", default-features = false, features = [
85-
"web",
86-
] }
8784
bevy_reflect = { path = "../bevy_reflect", version = "0.17.0-dev", default-features = false, features = [
8885
"web",
8986
] }

crates/bevy_diagnostic/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ std = [
3838
"bevy_app/std",
3939
"bevy_platform/std",
4040
"bevy_time/std",
41-
"bevy_tasks/std",
41+
"bevy_utils/std",
4242
]
4343

4444
## `critical-section` provides the building blocks for synchronization primitives
@@ -48,7 +48,7 @@ critical-section = [
4848
"bevy_app/critical-section",
4949
"bevy_platform/critical-section",
5050
"bevy_time/critical-section",
51-
"bevy_tasks/critical-section",
51+
"bevy_utils/critical-section",
5252
]
5353

5454
[dependencies]

crates/bevy_ecs/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ async_executor = ["std", "bevy_tasks/async_executor"]
6161
## supported platforms.
6262
std = [
6363
"bevy_reflect?/std",
64-
"bevy_tasks/std",
65-
"bevy_utils/parallel",
6664
"bevy_utils/std",
6765
"bitflags/std",
6866
"concurrent-queue/std",
@@ -78,7 +76,6 @@ std = [
7876
## `critical-section` provides the building blocks for synchronization primitives
7977
## on all platforms, including `no_std`.
8078
critical-section = [
81-
"bevy_tasks/critical-section",
8279
"bevy_platform/critical-section",
8380
"bevy_reflect?/critical-section",
8481
]

crates/bevy_internal/Cargo.toml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ std = [
327327
"bevy_state?/std",
328328
"bevy_time/std",
329329
"bevy_transform/std",
330-
"bevy_tasks/std",
330+
"bevy_utils/std",
331331
"bevy_window?/std",
332332
]
333333

@@ -344,7 +344,7 @@ critical-section = [
344344
"bevy_reflect/critical-section",
345345
"bevy_state?/critical-section",
346346
"bevy_time/critical-section",
347-
"bevy_tasks/critical-section",
347+
"bevy_utils/critical-section",
348348
]
349349

350350
# Uses the `libm` maths library instead of the one provided in `std` and `core`.
@@ -368,12 +368,7 @@ async_executor = [
368368

369369
# Enables use of browser APIs.
370370
# Note this is currently only applicable on `wasm32` architectures.
371-
web = [
372-
"bevy_app/web",
373-
"bevy_platform/web",
374-
"bevy_reflect/web",
375-
"bevy_tasks/web",
376-
]
371+
web = ["bevy_app/web", "bevy_platform/web", "bevy_reflect/web"]
377372

378373
hotpatching = ["bevy_app/hotpatching", "bevy_ecs/hotpatching"]
379374

crates/bevy_platform/Cargo.toml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ std = [
3232
"spin/std",
3333
"foldhash/std",
3434
"serde?/std",
35+
"wasm-bindgen-futures?/std",
36+
"futures-channel/std",
37+
"wasm-bindgen?/std",
38+
"js-sys?/std",
3539
]
3640

3741
## Allows access to the `alloc` crate.
@@ -43,7 +47,14 @@ critical-section = ["dep:critical-section", "portable-atomic/critical-section"]
4347

4448
## Enables use of browser APIs.
4549
## Note this is currently only applicable on `wasm32` architectures.
46-
web = ["dep:web-time", "dep:getrandom"]
50+
web = [
51+
"std",
52+
"dep:web-time",
53+
"dep:getrandom",
54+
"dep:wasm-bindgen-futures",
55+
"dep:wasm-bindgen",
56+
"dep:js-sys",
57+
]
4758

4859
[dependencies]
4960
critical-section = { version = "1.2.0", default-features = false, optional = true }
@@ -68,6 +79,10 @@ web-time = { version = "1.1", default-features = false, optional = true }
6879
getrandom = { version = "0.2.0", default-features = false, optional = true, features = [
6980
"js",
7081
] }
82+
wasm-bindgen-futures = { version = "0.4", default-features = false, optional = true }
83+
futures-channel = { version = "0.3", default-features = false }
84+
js-sys = { version = "0.3", default-features = false, optional = true }
85+
wasm-bindgen = { version = "0.2", default-features = false, optional = true }
7186

7287
[target.'cfg(not(all(target_has_atomic = "8", target_has_atomic = "16", target_has_atomic = "32", target_has_atomic = "64", target_has_atomic = "ptr")))'.dependencies]
7388
portable-atomic = { version = "1", default-features = false, features = [

crates/bevy_platform/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,14 @@ pub mod prelude {
5151
// * println
5252
// * thread_local
5353
}
54+
55+
/// Re-exports of crates that are useful across Bevy.
56+
/// Not intended for external crates to use.
57+
#[doc(hidden)]
58+
pub mod exports {
59+
crate::cfg::web! {
60+
pub use js_sys;
61+
pub use wasm_bindgen;
62+
pub use wasm_bindgen_futures;
63+
}
64+
}

crates/bevy_render/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ wasm-bindgen = "0.2"
144144
bevy_app = { path = "../bevy_app", version = "0.17.0-dev", default-features = false, features = [
145145
"web",
146146
] }
147-
bevy_tasks = { path = "../bevy_tasks", version = "0.17.0-dev", default-features = false, features = [
148-
"web",
149-
] }
150147
bevy_platform = { path = "../bevy_platform", version = "0.17.0-dev", default-features = false, features = [
151148
"web",
152149
] }

crates/bevy_tasks/Cargo.toml

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,27 @@ license = "MIT OR Apache-2.0"
99
keywords = ["bevy"]
1010

1111
[features]
12-
default = ["std", "async_executor"]
12+
default = ["async_executor", "futures-lite"]
1313

14-
# Functionality
15-
16-
## Enables multi-threading support.
17-
## Without this feature, all tasks will be run on a single thread.
14+
# Enables multi-threading support.
15+
# Without this feature, all tasks will be run on a single thread.
1816
multi_threaded = [
19-
"std",
17+
"bevy_platform/std",
2018
"dep:async-channel",
2119
"dep:concurrent-queue",
2220
"async_executor",
2321
]
2422

25-
## Uses `async-executor` as a task execution backend.
26-
## This backend is incompatible with `no_std` targets.
27-
async_executor = ["std", "dep:async-executor"]
28-
29-
# Platform Compatibility
23+
# Uses `async-executor` as a task execution backend.
24+
# This backend is incompatible with `no_std` targets.
25+
async_executor = ["bevy_platform/std", "dep:async-executor"]
3026

31-
## Allows access to the `std` crate. Enabling this feature will prevent compilation
32-
## on `no_std` targets, but provides access to certain additional features on
33-
## supported platforms.
34-
std = ["futures-lite/std", "async-task/std", "bevy_platform/std"]
27+
# Provide an implementation of `block_on` from `futures-lite`.
28+
futures-lite = ["bevy_platform/std", "futures-lite/std"]
3529

36-
## `critical-section` provides the building blocks for synchronization primitives
37-
## on all platforms, including `no_std`.
38-
critical-section = ["bevy_platform/critical-section"]
39-
40-
## Enables use of browser APIs.
41-
## Note this is currently only applicable on `wasm32` architectures.
42-
web = [
43-
"bevy_platform/web",
44-
"dep:wasm-bindgen-futures",
45-
"dep:pin-project",
46-
"dep:futures-channel",
47-
]
30+
# Use async-io's implementation of block_on instead of futures-lite's implementation.
31+
# This is preferred if your application uses async-io.
32+
async-io = ["bevy_platform/std", "dep:async-io"]
4833

4934
[dependencies]
5035
bevy_platform = { path = "../bevy_platform", version = "0.17.0-dev", default-features = false, features = [
@@ -59,7 +44,6 @@ derive_more = { version = "2", default-features = false, features = [
5944
"deref",
6045
"deref_mut",
6146
] }
62-
cfg-if = "1.0.0"
6347
async-executor = { version = "1.11", optional = true }
6448
async-channel = { version = "2.3.0", optional = true }
6549
async-io = { version = "2.0.0", optional = true }
@@ -70,9 +54,8 @@ crossbeam-queue = { version = "0.3", default-features = false, features = [
7054
] }
7155

7256
[target.'cfg(target_arch = "wasm32")'.dependencies]
73-
wasm-bindgen-futures = { version = "0.4", optional = true }
74-
pin-project = { version = "1", optional = true }
75-
futures-channel = { version = "0.3", optional = true }
57+
pin-project = { version = "1" }
58+
futures-channel = { version = "0.3", default-features = false }
7659

7760
[target.'cfg(not(all(target_has_atomic = "8", target_has_atomic = "16", target_has_atomic = "32", target_has_atomic = "64", target_has_atomic = "ptr")))'.dependencies]
7861
async-task = { version = "4.4.0", default-features = false, features = [
@@ -85,6 +68,11 @@ atomic-waker = { version = "1", default-features = false, features = [
8568
"portable-atomic",
8669
] }
8770

71+
[dev-dependencies]
72+
futures-lite = { version = "2.0.1", default-features = false, features = [
73+
"std",
74+
] }
75+
8876
[lints]
8977
workspace = true
9078

crates/bevy_tasks/src/executor.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use core::{
1414
};
1515
use derive_more::{Deref, DerefMut};
1616

17-
cfg_if::cfg_if! {
18-
if #[cfg(feature = "async_executor")] {
17+
crate::cfg::async_executor! {
18+
if {
1919
type ExecutorInner<'a> = async_executor::Executor<'a>;
2020
type LocalExecutorInner<'a> = async_executor::LocalExecutor<'a>;
2121
} else {
@@ -24,8 +24,9 @@ cfg_if::cfg_if! {
2424
}
2525
}
2626

27-
#[cfg(all(feature = "multi_threaded", not(target_arch = "wasm32")))]
28-
pub use async_task::FallibleTask;
27+
crate::cfg::multi_threaded! {
28+
pub use async_task::FallibleTask;
29+
}
2930

3031
/// Wrapper around a multi-threading-aware async executor.
3132
/// Spawning will generally require tasks to be `Send` and `Sync` to allow multiple

0 commit comments

Comments
 (0)