Note While I use 12 cores, you should use the number of cores on your machine. If we increase this…
Technical requirements – Runtimes, Wakers, and the Reactor-Executor Pattern
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 MoreFinal thoughts – Coroutines and async/await
Before we round off this chapter, I want to point out that it should now be clear to us why coroutines aren’t really pre-emptable. If you remember back in Chapter […]
Read MoreIMPORTANT – Coroutines and async/await
There is one subtle point to make a note of here. The first time JoinAll::poll is called, it will call poll on each future in the collection. Polling each future […]
Read Morec-async-await-concurrent futures – Coroutines and async/await
Okay, so we’ll build on the last example and do just the same thing. Create a new project called c-async-await and copy Cargo.toml and everything in the src folder over. […]
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 MoreNOTE – Coroutines and async/await-1
We could have simply defined Coroutine as an enum since the only state it holds is an enum indicating its state. But, we’ll set up this example so we can […]
Read More