-
Notifications
You must be signed in to change notification settings - Fork 342
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
Make async spawn take a closure #1072
Comments
What is the backwards compatibility story on this? |
@Fishrock123 this is not backward compatible with current spawning API. After some discussion on the topic I think that a backward compatible approach is to: Offer another multithreaded executor that pins tasks to threads. This executor shall use the spawn function proposed by matklad delivering better DX to those of us who do not think that work stealing is essential to handling our workloads (Sometimes it's fine to just distribute tasks at creation time fairly between the worker threads). The current work stealing executor will still exist with its current clunky not too developer friendly spawn API... until language developers "fix" this issue of entangling of Send with OS threads |
Interestingly, this is an option that CloudFlare's And their runtime has this comment in the source code: //! Pingora tokio runtime.
//!
//! Tokio runtime comes in two flavors: a single-threaded runtime
//! and a multi-threaded one which provides work stealing.
//! Benchmark shows that, compared to the single-threaded runtime, the multi-threaded one
//! has some overhead due to its more sophisticated work steal scheduling.
//!
//! This crate provides a third flavor: a multi-threaded runtime without work stealing.
//! This flavor is as efficient as the single-threaded runtime while allows the async
//! program to use multiple cores.
|
Hello,
I'm posting this idea to many Rust async runtimes discussion threads in order to push for the alternative design of the task spawn API described by @matklad in https://matklad.github.io/2023/12/10/nsfw.html
If you think that this is the right direction for rust to take, I suggest to do the following to arrive at the destination ASAP:
What do you think?
The text was updated successfully, but these errors were encountered: