reworked chapter 2 and added new chapter 3 ref #25

This commit is contained in:
Carl Fredrik Samson
2020-12-22 19:39:26 +01:00
parent b5ce4ff4c3
commit b085fdd966
26 changed files with 78 additions and 9 deletions

Binary file not shown.

View File

@@ -145,11 +145,8 @@ communicate with one another directly.**.
This design is what gives the futures framework it's power and flexibility and allows the Rust
standard library to provide an ergonomic, zero-cost abstraction for us to use.
In an effort to try to visualize how these parts work together in a simple program I created this
GIF. Note that the code is "pseudo-Rust" to help us focus on the important parts:
#### Fig 2: Simplified flow in an async system
![futures_animation](./assets/futures_animation.gif)
In an effort to try to visualize how these parts work together I put together
a set of slides in the next chapter that I hope will help.
The two most popular runtimes for Futures as of writing this is:

View File

@@ -0,0 +1,71 @@
# Get a mental model of how Futures and runtimes work
In this chapter we'll try to build a high level mental model of how Futures and
runtimes work together. Just note that the code itself is "pseudo-rust" due to space
restrictions and clarity. The main goal in this part is to create a high level
understanding to make it easier to learn. This is not the only way to model this
since we're making assumtions on runtime specifics that can vary a great deal,
but it's the way I found it easiest to build upon.
>Click on a page to open a larger view of it in a new tab.
>
>_Thanks to [@ckaran](https://github.com/ckaran) for feedback and [discussions](https://github.com/cfsamson/books-futures-explained/issues/25) on
this chapter._
<a href="./assets/slides/Slide1.PNG" target="_blank">
<img src="./assets/slides/Slide1.PNG" alt="slide1"/>
</a>
<a href="./assets/slides/Slide2.PNG" target="_blank">
<img src="./assets/slides/Slide2.PNG" alt="slide2"/>
</a>
<a href="./assets/slides/Slide3.PNG" target="_blank">
<img src="./assets/slides/Slide3.PNG" alt="slide3"/>
</a>
<a href="./assets/slides/Slide4.PNG" target="_blank">
<img src="./assets/slides/Slide4.PNG" alt="slide4"/>
</a>
<a href="./assets/slides/Slide5.PNG" target="_blank">
<img src="./assets/slides/Slide5.PNG" alt="slide5"/>
</a>
<a href="./assets/slides/Slide6.PNG" target="_blank">
<img src="./assets/slides/Slide6.PNG" alt="slide6"/>
</a>
<a href="./assets/slides/Slide7.PNG" target="_blank">
<img src="./assets/slides/Slide7.PNG" alt="slide7"/>
</a>
<a href="./assets/slides/Slide8.PNG" target="_blank">
<img src="./assets/slides/Slide8.PNG" alt="slide8"/>
</a>
<a href="./assets/slides/Slide9.PNG" target="_blank">
<img src="./assets/slides/Slide9.PNG" alt="slide9"/>
</a>
<a href="./assets/slides/Slide10.PNG" target="_blank">
<img src="./assets/slides/Slide10.PNG" alt="slide10"/>
</a>
<a href="./assets/slides/Slide11.PNG" target="_blank">
<img src="./assets/slides/Slide11.PNG" alt="slide11"/>
</a>
<a href="./assets/slides/Slide12.PNG" target="_blank">
<img src="./assets/slides/Slide12.PNG" alt="slide12"/>
</a>
<a href="./assets/slides/Slide13.PNG" target="_blank">
<img src="./assets/slides/Slide13.PNG" alt="slide13"/>
</a>
<a href="./assets/slides/Slide14.PNG" target="_blank">
<img src="./assets/slides/Slide14.PNG" alt="slide14"/>
</a>
<a href="./assets/slides/Slide15.PNG" target="_blank">
<img src="./assets/slides/Slide15.PNG" alt="slide15"/>
</a>
<a href="./assets/slides/Slide16.PNG" target="_blank">
<img src="./assets/slides/Slide16.PNG" alt="slide16"/>
</a>
<a href="./assets/slides/Slide17.PNG" target="_blank">
<img src="./assets/slides/Slide17.PNG" alt="slide17"/>
</a>
<a href="./assets/slides/Slide18.PNG" target="_blank">
<img src="./assets/slides/Slide18.PNG" alt="slide18"/>
</a>
<a href="./assets/slides/Slide19.PNG" target="_blank">
<img src="./assets/slides/Slide19.PNG" alt="slide19"/>
</a>

View File

@@ -4,10 +4,11 @@
- [Background information](./0_background_information.md)
- [Futures in Rust](./1_futures_in_rust.md)
- [Waker and Context](./2_waker_context.md)
- [Generators and async/await](./3_generators_async_await.md)
- [Pin](./4_pin.md)
- [A mental model for Futures](./2_a_mental_model_for_futures.md)
- [Waker and Context](./3_waker_context.md)
- [Generators and async/await](./4_generators_async_await.md)
- [Pin](./5_pin.md)
- [Implementing Futures](./6_future_example.md)
- [Finished example (editable)](./8_finished_example.md)
- [Finished example (editable)](./7_finished_example.md)
[Conclusion and exercises](./conclusion.md)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 44 KiB