This commit is contained in:
Carl Fredrik Samson
2020-01-25 17:25:06 +01:00
parent bf2d29fea5
commit 5ece5dc585
3 changed files with 37 additions and 7 deletions

7
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,7 @@
{
"spellright.language": [],
"spellright.documentTypes": [
"latex",
"plaintext"
]
}

View File

@@ -1,5 +1,7 @@
# Thought dump
The repository for the book [Future Explained in 200 Lines of Rust](https://cfsamson.github.io/books-futures-explained/)
### Data + Vtable
We need to get a basic grasp of this to be able to understand how we implement a Waker.

View File

@@ -6,13 +6,34 @@ information that will help demystify some of the concepts we encounter.
## Concurrency in general
If you find the concepts of concurrency and async programming confusing in
general, I'd recommend that you spend a little time exploring some of the
basic concepts first. Learning `Futures` in Rust is not the best introduction
to the subject.
general, I know where you're coming from and I have written some resources to
try to give a high level overview that will make it easier to learn Rusts
`Futures` afterwards:
I have spent quite a bit of time digging into these subjects myself, and I'll
point you to some of thos sources
[Async Basics - The difference between concurrency and parallelism](https://cfsamson.github.io/book-exploring-async-basics/1_concurrent_vs_parallel.html)
[Async Basics - Async history](https://cfsamson.github.io/book-exploring-async-basics/2_async_history.html)
[Async Basics - Strategies for handling I/O](https://cfsamson.github.io/book-exploring-async-basics/5_strategies_for_handling_io.html)
[Async Basics - Epoll, Kqueue and IOCP](https://cfsamson.github.io/book-exploring-async-basics/6_epoll_kqueue_iocp.html)
**The absolute minimum**
## Trait objects and dynamic dispatch
[Async Basics - The Difference Between Concurrency And Parallelism]()
The single most confusing topic we encounter when implementing our own `Futures`
is how we implement a `Waker`. Creating a `Waker` involves creating a `vtable`
which allows using dynamic dispatch to call methods on a _type erased_ trait
object we construct our selves.
If you want to know more about dynamic dispatch in Rust I can recommend this article:
https://alschwalm.com/blog/static/2017/03/07/exploring-dynamic-dispatch-in-rust/
Let's explain this a bit more in detail.
## Fat pointers in Rust
Let's take a look at the size of some different pointer types in Rust. If we
run the following code:
```rust
```