by moosingin3space · 9y ago · 0 comments
* Futures is a crate that provides a common abstraction for delimited continuations (JavaScript Promises).
* Tokio-Core provides an event loop abstraction (can't remember for sure but I think it uses Mio under the hood to abstract out epoll/kqueue/IOCP). Additionally, it provides the "core language" of Tokio, which are Futures (basically a Result that returns asynchronously), Streams (an Iterator that yields values asynchronously), and Sinks (a place to send data asynchronously).
* Tokio-Proto is an abstraction over Tokio-Core for composing various protocols together. This is done by defining protocol "codecs", which are used to define Streams and Sinks that send some unit of data along the protocol, and a Proto object that ties the codecs together. Then, to write servers with that protocol, you implement the Service trait, which can work at the higher-level protocol units (requests, responses, etc). If you're curious how this looks in an HTTP server for example, check out this (shameless plug) reverse proxy I wrote with Tokio: https://github.com/moosingin3space/hyproxy
* You would use Tokio for any asynchronous I/O task. You would use Futures whenever you want some sort of delimited continuation.
* You can use Futures without Tokio.
* The examples are mostly in the documentation here: https://tokio.rs/docs/getting-started/tokio/
If I'm wrong about any of this, please, someone, let me know!
I'm familiar with Java Futures, but can't tell if it's the same concept as what you're talking about. What exactly is a "delimited continuation"?
A "delimited continuation" is that basic idea of having your code pick up once a future finishes executing.
E: I meant to reply to a a sibling.