updated intro

This commit is contained in:
cfsamson
2020-01-31 19:38:34 +01:00
parent ba0b90e921
commit b180e1aa2c
4 changed files with 25 additions and 15 deletions

View File

@@ -5,9 +5,12 @@ This book aims to explain `Futures` in Rust using an example driven approach.
The goal is to get a better understanding of `Futures` by implementing a toy
`Reactor`, a very simple `Executor` and our own `Futures`.
We'll start off solving a small problem without `Futures`, `Wakers` or async/await
and then gradually adapt our example so it implements all these concepts, and
can be solved using the executor provided by both `tokio` and `async_str`.
We'll start off a bit untraditionally. Instead of deferring some of the details about what's
special about futures in Rust we try to tackle that head on first. We'll be as brief as possible,
but as thorough as needed. I findt that implementing and understanding `Futures` is a lot easier
then. Actually, most questions will be answered up front.
We'll end up with futures that can run an any executor like `tokio` and `async_str`.
In the end I've made some reader excercises you can do if you want to fix some
of the most glaring ommissions and shortcuts we took and create a slightly better
@@ -17,7 +20,7 @@ example yourself.
That's a valid question. There are many good resources and examples already. First
of all, this book will point you to some background information that I have found
very valuable to get an understanding of concurrent programming in general.
very valuable, especially `Generators` and stackless coroutines.
I find that many discussions arise, not because `Futures` is a hard concept to
grasp, but that concurrent programming is a hard concept in general.

View File

@@ -22,5 +22,11 @@ Now learning these concepts by studying futures is making it much harder than
it needs to be, so go on and read these chapters. I'll be right here when
you're back.
However, if you feel that you have the basics covered, then go right on. Let's
get moving!
However, if you feel that you have the basics covered, then go right on. The concepts we need to
learn are:
1. Trait Objects and fat pointers
2. Generators/stackless coroutines
3. Pinning, what it is and why we need it
Let's get moving!

View File

@@ -1,9 +1,10 @@
# Generators and Pin
# Generators
So the second difficult part that there seems to be a lot of questions about
is Generators and the `Pin` type.
## Generators
is Generators and the `Pin` type. Since they're related we'll start off by
undertanding generators first. By doing that we'll soon get to see why
we need to be able to "pin" some data to a fixed location in memory and
get an introduction to `Pin` as well.
>**Relevant for:**
@@ -29,8 +30,8 @@ I've written about green threads before. Go check out
[Green Threads Explained in 200 lines of Rust][greenthreads] if you're interested.
Green threads uses the same mechanisms as an OS does by creating a thread for
each task, setting up a stack and forcing the CPU to save it's state and jump
from one task(thread) to another. We yield control to the scheduler which then
each task, setting up a stack, save the CPU's state and jump
from one task(thread) to another by doing a "context switch". We yield control to the scheduler which then
continues running a different task.
Rust had green threads once, but they were removed before it hit 1.0. The state

View File

@@ -2,8 +2,8 @@
- [Introduction](./0_0_introduction.md)
- [Some background information](./1_0_background_information.md)
- [Trait objects and fat pointers](./1_1_trait_objects.md)
- [Generators and Pin](./1_2_generators_pin.md)
- [Pin](./1_3_pin.md)
- [Trait objects and fat pointers](./1_1_trait_objects.md)
- [Generators and Pin](./1_2_generators_pin.md)
- [Pin](./1_3_pin.md)
- [The main example](./2_0_future_example.md)
- [Bonus 1: concurrent futures](2_1_concurrent_futures.md)