Skip to content

Commit

Permalink
wasm: document that Tokio may use blocking ops
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Mar 10, 2025
1 parent afd3678 commit 5de8a69
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tokio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,11 @@
//! Enabling any other feature (including `full`) will cause a compilation
//! failure.
//!
//! When using `WASM` with multiple threads, support for blocking calls is
//! required. This means that, for example, using a Tokio mpsc channel to send
//! messages from a web worker to the main browser context will not work, as the
//! main browser context does not support blocking.
//!
//! The `time` module will only work on `WASM` platforms that have support for
//! timers (e.g. wasm32-wasi). The timing functions will panic if used on a `WASM`
//! platform that does not support timers.
Expand Down
6 changes: 6 additions & 0 deletions tokio/src/sync/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@
//! As an exception, methods ending in `_timeout` are not runtime agnostic
//! because they require access to the Tokio timer. See the documentation of
//! each `*_timeout` method for more information on its use.
//!
//! This module is also compatible with WASM, with one caveat: Tokio may use
//! blocking operations when more than one thread is involved. This means that,
//! for example, using a Tokio mpsc channel to send messages from a web worker
//! to the main browser context will not work, as the main browser context does
//! not support blocking operations.
cfg_sync! {
/// Named future types.
Expand Down

0 comments on commit 5de8a69

Please sign in to comment.