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

Compat with tokio::spawn #15

Open
jon-chuang opened this issue Feb 25, 2022 · 1 comment
Open

Compat with tokio::spawn #15

jon-chuang opened this issue Feb 25, 2022 · 1 comment

Comments

@jon-chuang
Copy link

jon-chuang commented Feb 25, 2022

It would be very cool if a Compat could be produced for consuming the Spawner in the Tokio Handler so that the non-tokio runtime can spawn Tokio tasks.

The way I'm thinking to do it is to first, have the background thread do a sleep(u64::MAX) so that it can never process any spawned tasks.

Then, we hijack the Spawner from the handler (currently impossible as spawner field along with other needed data types are pub(crate)) and process tasks from it by putting them onto the current runtime's task queue.

@inevity
Copy link

inevity commented Mar 4, 2022

When case do you mean: futures::executor::block_on or tokio::main/tokio::block_on? Give an example?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants