Skip to content
crates · rust · bevy

Cross-platform async tasks forbevy_tasker

Cross-platform async task spawning for Bevy — a desktop thread pool or WASM web workers / microtask queue behind one API, so game code stays identical on every target.

One API, every target

It presents one API — spawn and spawn_local — that maps to a desktop thread pool or to WASM web workers / microtask queue depending on the target, so game code stays identical everywhere.

RustBevy crate
threadsDesktop
workersWASM
MITLicense

What it gives you

Features

Desktop thread pool

Tasks run on a pool sized to std::thread::available_parallelism, wired through crossbeam channels.

WASM microtask queue

Without atomics, tasks run via the browser's queueMicrotask.

WASM web workers

With atomics, spawn dispatches Send futures to web workers via a shared work queue.

Pinned local tasks

spawn_local pins !Send futures to the spawning thread via Atomics.waitAsync.

Uniform API

Every path returns an async_task::Task; await, drop to detach, or .cancel().

Get started

Usage

main.rs
use bevy_tasker::spawn;

let task = spawn(async {
    42
});

Questions

Frequently asked

What does the bevy_tasker crate do?

It provides cross-platform async task spawning for Bevy games. On desktop it runs tasks on a thread pool sized to available parallelism; on WASM it dispatches work to the browser microtask queue or web workers, all behind one API.

How does bevy_tasker behave on WASM versus desktop?

On WASM without atomics tasks run via queueMicrotask; with atomics, spawn dispatches Send futures to web workers via a shared work queue and spawn_local pins non-Send futures to the spawning thread. On desktop tasks run on a crossbeam-channel-backed thread pool.

Is the bevy_tasker API the same across platforms?

Yes. Every path returns an async_task::Task, so calling code is identical across targets — await it, drop it to detach, or cancel it.