Skip to content

Commit 766f966

Browse files
committed
use web_task for cancellable wasm tasks
1 parent be4114b commit 766f966

File tree

5 files changed

+7
-221
lines changed

5 files changed

+7
-221
lines changed

crates/bevy_tasks/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ crossbeam-queue = { version = "0.3", default-features = false, features = [
5454
] }
5555

5656
[target.'cfg(target_arch = "wasm32")'.dependencies]
57-
pin-project = "1"
58-
async-channel = { version = "2.3.0", default-features = false }
57+
web-task = "1"
5958

6059
[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]
6160
async-task = { version = "4.4.0", default-features = false, features = [

crates/bevy_tasks/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ mod executor;
7676
pub mod futures;
7777
mod iter;
7878
mod slice;
79-
mod task;
8079
mod usages;
8180

8281
cfg::async_executor! {
@@ -88,7 +87,7 @@ cfg::async_executor! {
8887
// Exports
8988
pub use iter::ParallelIterator;
9089
pub use slice::{ParallelSlice, ParallelSliceMut};
91-
pub use task::Task;
90+
pub use async_task::Task;
9291
pub use usages::{AsyncComputeTaskPool, ComputeTaskPool, IoTaskPool};
9392

9493
pub use futures_lite;

crates/bevy_tasks/src/single_threaded_task_pool.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl TaskPool {
194194
{
195195
crate::cfg::switch! {{
196196
crate::cfg::web => {
197-
Task::wrap_future(future)
197+
web_task::spawn_local(future)
198198
}
199199
crate::cfg::std => {
200200
LOCAL_EXECUTOR.with(|executor| {
@@ -330,13 +330,13 @@ crate::cfg::std! {
330330
if {
331331
pub trait MaybeSend {}
332332
impl<T> MaybeSend for T {}
333-
333+
334334
pub trait MaybeSync {}
335335
impl<T> MaybeSync for T {}
336336
} else {
337337
pub trait MaybeSend: Send {}
338338
impl<T: Send> MaybeSend for T {}
339-
339+
340340
pub trait MaybeSync: Sync {}
341341
impl<T: Sync> MaybeSync for T {}
342342
}

crates/bevy_tasks/src/task.rs

Lines changed: 0 additions & 212 deletions
This file was deleted.

crates/bevy_tasks/src/task_pool.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ impl TaskPool {
560560
where
561561
T: Send + 'static,
562562
{
563-
Task::new(self.executor.spawn(future))
563+
self.executor.spawn(future)
564564
}
565565

566566
/// Spawns a static future on the thread-local async executor for the
@@ -578,7 +578,7 @@ impl TaskPool {
578578
where
579579
T: 'static,
580580
{
581-
Task::new(TaskPool::LOCAL_EXECUTOR.with(|executor| executor.spawn(future)))
581+
TaskPool::LOCAL_EXECUTOR.with(|executor| executor.spawn(future))
582582
}
583583

584584
/// Runs a function with the local executor. Typically used to tick

0 commit comments

Comments
 (0)