Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wasm: document that Tokio may use blocking ops #7207

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not the case just for thread -> main thread, but other way around as well. So when sending messages from main thread to other threads.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just this. Otherwise looks good to me. Thanks @Darksonn!

cfg_sync! {
/// Named future types.
Expand Down
Loading