Pinning¶
Category: Async · Status: stub · Lessons: chapter 06, Async (planned)
One line: Rust's guarantee that a value will not move in memory, needed because an async state machine may hold pointers into itself.
Also called: Pin, Unpin.
How it connects¶
- See also: Async functions as state machines
In each language¶
| Rust | Pin ↗ keeps a pointee from being moved unless it implements Unpin |
| C# | a different pinning: fixed ↗ stops the garbage collector from relocating a variable while a pointer to it is in use, and so does a Pinned ↗ GCHandle |
Where to read more¶
- In the books: Asynchronous Programming in Rust, Carl Fredrik Samson — ch. 9, 'Coroutines, Self-Referential Structs, and Pinning'
- In the books: Programming Rust, Jim Blandy, Jason Orendorff, Leonora F. S. Tindall — ch. 20, 'Asynchronous Programming' → 'Pinning'
- Reference: Rust std: module pin ↗