Improving our base example
We’ll create a version of the first example in Chapter 7 since it’s the simplest one to start with. Our only focus is showing how to schedule and drive the runtimes more efficiently.
We start with the following steps:
- Create a new project and name it
a-runtime
(alternatively, navigate toch08/a-runtime
in the book’s repository). - Copy the
future.rs
andhttp.rs
files in thesrc
folder from the first project we created in Chapter 7, nameda-coroutine
(alternatively, copy the files fromch07/a-coroutine
in the book’s repository) to thesrc
folder in our new project. - Make sure to add
mio
as a dependency by adding the following toCargo.toml
:[dependencies] mio = { version = "0.8", features = ["net", "os-poll"] }
- Create a new file in the
src
folder calledruntime.rs
.
We’ll use corofy
to change the following coroutine/wait
program into its state machine representation that...