async-compat icon indicating copy to clipboard operation
async-compat copied to clipboard

Compat with tokio::spawn

Open jon-chuang opened this issue 3 years ago • 1 comments

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.

jon-chuang avatar Feb 25 '22 12:02 jon-chuang

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

inevity avatar Mar 04 '22 06:03 inevity