The key idea is that you give something a bunch of event sources and it waits for something to happen.
MIO (Rust)
- Create a poll instance
- Populate it with event sources (Like TCPListeners)
- Wait for events in an event poll
- There are examples of using this in the lecture slides
Async Networking
A get request from the reqwest library returns a Future. You need to await these.
There are many definitions of async/await and the one you use depends on your context.
The simplest await just blocks and waits for a result to be ready. When there are multiple awaits, tokio can multiplex into different threads. You can specify the executor (where the definition of async/await comes from) with #[tokio::main], etc.
Using a multi-handle, you can start a new network request and create more without waiting on the result of the first one (as opposed to using easy-handles).
You can put easy handles in the multiple handle and make a perform() call to dispatch them, the return is the number of easy_handles that are still running, when this reaches 0 we are done. This means we may need to call perform more than once.
What we are looking for here, is that the msg param has a result_for meaning that the request is done. Then a handle is finished it needs to be removed from the multi-handle. Look this up. You can reuse an easy handle by removing the easy handle and adding it back to the multi-handle.