- Notifications
You must be signed in to change notification settings - Fork341
Open
Description
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 inhttps://matklad.github.io/2023/12/10/nsfw.html
// std::thread::spawnpubfnspawn<F,T>(f:F) ->JoinHandle<T>whereF:FnOnce() ->T +Send +'static,T:Send +'static{}// A hypothetical better async spawnpubfnspawn<F,Fut>(f:F) ->JoinHandle<Fut::Output>whereF:FnOnce() ->Fut +Send +'static,Fut:Future,Fut::Output:Send +'static{}
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:
- change task spawn definition to one that takes a closure returning a future
- Provide a safe executor constructor that pins tasks to threads
- Make workstealing executors unsafe to construct... until the language developers "fix" this issue of entangling of Send with OS threads
What do you think?
Metadata
Metadata
Assignees
Labels
No labels