Skip to content

Async Task for WASM #3351

Answered by vladbat00
samcarey asked this question in Q&A
Dec 16, 2021 · 3 comments · 4 replies
Discussion options

You must be logged in to vote

I wasn't able to use tasks like this in WASM as well. I had to detach FakeTask, and then use channels to communicate between the task and my game systems.

For example, here's how I use AsyncComputeTaskPool in my project:
https://github.com/mvlabat/muddle-run/blob/b02374bf90f29a246c39d89ebf35ba49f53865b4/libs/shared_lib/src/game/level.rs#L161

The task isn't async itself, but I just needed to send a compute-heavy task to a task pool (it's a bad idea, I know, one shouldn't use the async task pool for this purpose), and I found it to be an easy hack that works for now.

This compiles for WASM as well.

But for web requests, I found that having a separate executor is a bit more convenient to use…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@samcarey
Comment options

@vladbat00
Comment options

@davidlampach
Comment options

Answer selected by samcarey
Comment options

You must be logged in to vote
1 reply
@simbleau
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
O-Web Specific to web (WASM) builds A-Tasks Tools for parallel and async work
6 participants