-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Add tokio as an optional bevy_tasks backend #6762
Conversation
|
||
let _guard = task_scope_runtime.enter(); | ||
loop { | ||
if let Some(result) = self.runtime.block_on(future::poll_once(&mut get_results)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The primary problem I'm finding is that tokio
's block_on does not allow us to internally tick another runtime without blocking. This might be what's causing the deadlock.
I would be very happy for |
Poked at this some more. So my current branch only allows one local executor to run in the whole task pool. https://github.com/hymm/bevy/tree/tokio. This breaks the 2 thread locality tests, since they need to run a local executor on every thread. Bevy is able to run ok though, since it doesn't actively use that functionality. I have a way of running multiple local executors, but it breaks when scopes are nested and the inner scope tries to tick it's local executor. Tokio complains about running one executor inside of another one. We need nested scopes since we use them when running par_for_each inside of a system. There are a couple possible fixes for this that I can see.
|
Backlog cleanup: nice idea, but still a WIP since 2022, so probably safe to close for now. @ me if I'm wrong! :) |
Objective
tokio
is the de facto ecosystem standard async executor for the Rust ecosystem. It was initially avoided as it doesn't support all of the target systems that Bevy aims to support (i.e. WASM).Solution
Add an optional feature flag for enabling
tokio
as a backing async executor for non-WASM platforms, and enable it by default for them. Usetokio::runtime::Runtime
as a replacement forasync_executor
.Note: this change conflicts heavily and is mutually exclusive with #4740. Additional care will needed to be taken to support all of the use cases of both options.
This PR is in a draft state as it currently deadlocks on something during normal program execution. This will need some investigation.
Changelog
Added:
tokio
as an optional and default backend async executor for non-WASM platforms.