save
This commit is contained in:
7
.vscode/settings.json
vendored
Normal file
7
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"spellright.language": [],
|
||||||
|
"spellright.documentTypes": [
|
||||||
|
"latex",
|
||||||
|
"plaintext"
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
# Thought dump
|
# Thought dump
|
||||||
|
|
||||||
|
The repository for the book [Future Explained in 200 Lines of Rust](https://cfsamson.github.io/books-futures-explained/)
|
||||||
|
|
||||||
### Data + Vtable
|
### Data + Vtable
|
||||||
|
|
||||||
We need to get a basic grasp of this to be able to understand how we implement a Waker.
|
We need to get a basic grasp of this to be able to understand how we implement a Waker.
|
||||||
|
|||||||
@@ -6,13 +6,34 @@ information that will help demystify some of the concepts we encounter.
|
|||||||
## Concurrency in general
|
## Concurrency in general
|
||||||
|
|
||||||
If you find the concepts of concurrency and async programming confusing in
|
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
|
general, I know where you're coming from and I have written some resources to
|
||||||
basic concepts first. Learning `Futures` in Rust is not the best introduction
|
try to give a high level overview that will make it easier to learn Rusts
|
||||||
to the subject.
|
`Futures` afterwards:
|
||||||
|
|
||||||
I have spent quite a bit of time digging into these subjects myself, and I'll
|
[Async Basics - The difference between concurrency and parallelism](https://cfsamson.github.io/book-exploring-async-basics/1_concurrent_vs_parallel.html)
|
||||||
point you to some of thos sources
|
[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
|
||||||
|
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user