So, while we’ve seen with our own eyes that the executor and reactor could be loosely coupled, which in turn means that you could in theory mix and match reactors
Read MoreCategory: What is a move?
NOTE – Creating Your Own Runtime
Calling Runtime::new creates a multithreaded Tokio runtime, but Tokio also has a single-threaded runtime that you can create by using the runtime builder like this: Builder::new_current_thread().enable_all().build().unwrap(). If you do that,
Read MoreExperimenting with our runtime – Creating Your Own Runtime
Note You’ll find this example in the book’s repository in the ch10/b-rust-futures-experiments folder. The different experiments will be implemented as different versions of the async_main function numbered chronologically. I’ll indicate
Read Morereactor.rs – Creating Your Own Runtime
The first thing we do is to make sure our dependencies are correct. We have to remove the dependency on our old Waker implementation and instead pull in these types
Read Moreexecutor.rs – Coroutines, Self-Referential Structs, and Pinning
The first thing we must do is make sure our dependencies are correct. The only change we’re making here is adding Pin from the standard library: ch09/e-coroutines-pin/src/runtime/executor.rs… thread::{self, Thread},pin::Pin,}; The next
Read Morehttp.rs – Coroutines, Self-Referential Structs, and Pinning
The first thing we need to do is pull in Pin from the standard library. The start of the file should look like this: ch09/e-coroutines-pin/src/http.rsuse crate::{future::PollState, runtime::{self, reactor, Waker}, Future};use
Read MorePin projections and structural pinning – Coroutines, Self-Referential Structs, and Pinning
Before we leave the topic of pinning, we’ll quickly explain what pin projections and structural pinning are. Both sound complex, but they are very simple in practice. The following diagram
Read MorePinning to the stack – Coroutines, Self-Referential Structs, and Pinning
Pinning to the stack can be somewhat difficult. In Chapter 5, we saw how the stack worked and we know that it grows and shrinks as values are popped and
Read MorePinning to the heap – Coroutines, Self-Referential Structs, and Pinning
Note The small code snippets we’ll present here can be found in this book’s GitHub repository in the ch09/d-pin folder. The different examples are implemented as different methods that you
Read MoreWhat is a move? – Coroutines, Self-Referential Structs, and Pinning
A move in Rust is one of those concepts that’s unfamiliar to many programmers coming from C#, Javascript, and similar garbage-collected languages, and different from what you’re used to for
Read More