In the previous chapter, we created our own pausable tasks (coroutines) by writing them as state machines. We created a common API for these tasks by requiring them to implement […]
Read MoreNOTE – Coroutines and async/await
For convenience, there is a file called original_main.rs in the root of the project that contains the code for main.rs that we presented, so you don’t need to save the […]
Read Moreb-async-await—an example of a coroutine/wait transformation – Coroutines and async/await
Let’s start by expanding our example slightly. Now that we have a program that writes out our state machines, it’s easier for us to create some examples and cover some […]
Read Morecoroutine/wait – Coroutines and async/await
The coroutine/wait syntax will have clear similarities to the async/await syntax, although it’s a lot more limited. The basic rules are as follows: Our implementation will make sure that if […]
Read MoreWho on earth wants to write code like this to accomplish a simple task? – Coroutines and async/await
The answer is no one! Yes, it’s a bit bombastic, but I dare guess that very few programmers prefer writing a 55-line state machine when you compare it to the […]
Read MoreNOTE – Coroutines and async/await-2
If anyone tries to call poll on our Coroutine again, we will panic, so the caller must make sure to keep track of when the future returns PollState::Ready and make […]
Read More