Some musings on the async ecosystem and compatibility between async-std and tokio... 1/15
-
Show this thread
-
When the async-std runtime was first introduced, some were worried that the async ecosystem would get split into two: one based on tokio and one based on async-std. Now I'm working on the third major runtime. Very soon we'll have a lot of different runtimes to choose from. 2/15
1 reply 2 retweets 5 likesShow this thread -
But remember, the Future trait and the futures crate have always been intentionally designed to be completely agnostic to the underlying runtimes. So there shouldn't be any fragmentation, no matter how many runtimes there are. 3/15
1 reply 1 retweet 5 likesShow this thread -
To avoid the ecosystem split, async libraries should not depend on async-std or tokio. Only binaries should use a runtime as a dependency. 4/15
2 replies 0 retweets 9 likesShow this thread -
The main question is then: what should async libraries do if they need to spawn futures or use types like TcpStream? The answer is that they shouldn't. And in most cases they really don't need to... 5/15
1 reply 1 retweet 6 likesShow this thread -
Instead of spawning a future, your async library should return the future to the user so that the user can spawn it however they want. 6/15
1 reply 1 retweet 8 likesShow this thread -
Instead of creating a TcpStream inside your async library, let the user create one for you and then accept any stream implementing AsyncRead and AsyncWrite as an argument. 7/15
5 replies 1 retweet 6 likesShow this thread -
Replying to @stjepang
Any ideas what an async timer library could look like? Apart from networking, I think timers are the other thing that currently split the ecosystem. How can I return a future to the user that includes some sort of delay somewhere?
1 reply 1 retweet 2 likes
I don't have a good answer to that question, unfortunately. Async timers are in the same realm as async networking. They require a runtime so it'd be great if libraries could push uses of timers onto the user. But I acknowledge that is not always easy nor the best solution...
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.