reworked chapter 2 and added new chapter 3 ref #25
@@ -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
|
||||

|
||||
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:
|
||||
|
||||
|
||||
71
src/2_a_mental_model_for_futures.md
Normal 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>
|
||||
@@ -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)
|
||||
|
||||
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 38 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 39 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 36 KiB |
|
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 35 KiB |
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 36 KiB |
BIN
src/assets/slides/Slide18.PNG
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
src/assets/slides/Slide19.PNG
Normal file
|
After Width: | Height: | Size: 34 KiB |
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 27 KiB |
|
Before Width: | Height: | Size: 44 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 50 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 33 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 31 KiB |
|
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 29 KiB |
|
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 44 KiB |