async-rs / async-rs/async-std

Feature request: block_on_blocking

Open
#801 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
4.1k
Forks
339
PR merge metrics
No merged PRs in 30d

Description

`async_std::task::spawn` spawns an asynchronous task.
`async_std::task::spawn_blocking` spawns a blocking task.
Both require the future/function to be `'static`.

`async_std::task::block_on` is like `spawn` but does not require `'static`.
In my mind this makes sense because we ensure that the future is used immediately. It works like [crossbeam's scope threads](https://docs.rs/crossbeam/0.7.3/crossbeam/thread/index.html).

If `block_on` is like `spawn` without `'static` then there should be an equivalent for `spawn_blocking` without `'static`. It could be called `block_on_blocking`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.