Skip to content

Commit 6df9f4a

Browse files
committed
fix wasm compilation
probably doesn't run correctly
1 parent 50696ae commit 6df9f4a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

crates/bevy_tasks/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ pub use task_pool::{Scope, TaskPool, TaskPoolBuilder};
1515
#[cfg(target_arch = "wasm32")]
1616
mod single_threaded_task_pool;
1717
#[cfg(target_arch = "wasm32")]
18-
pub use single_threaded_task_pool::{Scope, TaskPool, TaskPoolBuilder};
18+
pub use single_threaded_task_pool::{Scope, TaskPool, TaskPoolBuilder, ThreadExecutor};
1919

2020
mod usages;
2121
#[cfg(not(target_arch = "wasm32"))]
2222
pub use usages::tick_global_task_pools_on_main_thread;
2323
pub use usages::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool};
2424

25+
#[cfg(not(target_arch = "wasm32"))]
2526
mod main_thread_executor;
27+
#[cfg(not(target_arch = "wasm32"))]
2628
pub use main_thread_executor::ThreadExecutor;
2729

2830
mod iter;

crates/bevy_tasks/src/single_threaded_task_pool.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@ use std::{
99
#[derive(Debug, Default, Clone)]
1010
pub struct TaskPoolBuilder {}
1111

12+
/// dummy struct for wasm
13+
#[derive(Default)]
14+
pub struct ThreadExecutor;
15+
impl ThreadExecutor {
16+
/// creates a new `ThreadExecutor`
17+
pub fn new() -> Self {
18+
Self
19+
}
20+
}
21+
1222
impl TaskPoolBuilder {
1323
/// Creates a new TaskPoolBuilder instance
1424
pub fn new() -> Self {
@@ -62,7 +72,7 @@ impl TaskPool {
6272
/// to spawn tasks. This function will await the completion of all tasks before returning.
6373
///
6474
/// This is similar to `rayon::scope` and `crossbeam::scope`
65-
pub fn scope<'env, F, T>(&self, f: F) -> Vec<T>
75+
pub fn scope<'env, F, T>(&self, _thread_executor: Option<Arc<ThreadExecutor>>, f: F) -> Vec<T>
6676
where
6777
F: for<'scope> FnOnce(&'env mut Scope<'scope, 'env, T>),
6878
T: Send + 'static,

0 commit comments

Comments
 (0)