HTTP module – Coroutines and async/awaitHTTP module – Coroutines and async/await
In this module, we’ll implement a very simple HTTP client. This client can only make GET requests to our delayserver since we just use this as a representation of a
In this module, we’ll implement a very simple HTTP client. This client can only make GET requests to our delayserver since we just use this as a representation of a
The example we’ll use going forward is a simplified version of Rust’s asynchronous model. We’ll create and implement the following: So, to actually demystify coroutines, futures, and async/await, we will
Most often you’ll see stackless coroutines simply referred to as coroutines. To try to keep some consistency (you remember I don’t like to introduce terms that mean different things based
Now that you’ve gotten a brief introduction to Rust’s async model, it’s time to take a look at how this fits in the context of everything else we’ve covered in
Rust only provides what’s necessary to model asynchronous operations in the language. Basically, it provides the following: That’s really what Rust’s standard library does. As you see there is no
These are hex numbers indicating the offset from the memory pointer to which we want to read/write. I wrote down the base 10 numbers as comments, so as you can
There are a few functions we’ve referred to that are really important for our Runtime to actually work. Fortunately, all but one of them are extremely simple to understand. We’ll
Note I promised to point out where we close the impl Runtime block, and we do that after the spawn function. The upcoming functions are “free” functions that don’t belong
We need to explain the new concepts we introduced here. The assembly calls the function switch (the function is tagged with #[no_mangle] so we can call it by name). The
Before we start, I want to make sure you understand that the code we write is quite unsafe and is not a “best practice” when writing Rust. I want to