|
| 1 | +# More async/await topics |
| 2 | + |
| 3 | +## Unit tests |
| 4 | + |
| 5 | +## Blocking and cancellation |
| 6 | + |
| 7 | +- Two important concepts to be aware of early, we'll revisit in more detail as we go along |
| 8 | +- Cancellation |
| 9 | + - How to do it |
| 10 | + - drop a future |
| 11 | + - cancellation token |
| 12 | + - abort functions |
| 13 | + - Why it matters, cancellation safety (forward ref) |
| 14 | +- Blocking |
| 15 | + - IO and computation can block |
| 16 | + - why it's bad |
| 17 | + - how to deal is a forward ref to io chapter |
| 18 | + |
| 19 | +## `Send + 'static` bounds on futures |
| 20 | + |
| 21 | +- Why they're there, multi-threaded runtimes |
| 22 | +- spawn local to avoid them |
| 23 | +- What makes an async fn `Send + 'static` and how to fix bugs with it |
| 24 | + |
| 25 | +## Async traits |
| 26 | + |
| 27 | +- syntax |
| 28 | + - The `Send + 'static` issue and working around it |
| 29 | + - trait_variant |
| 30 | + - explicit future |
| 31 | + - return type notation (https://blog.rust-lang.org/inside-rust/2024/09/26/rtn-call-for-testing.html) |
| 32 | +- overriding |
| 33 | + - future vs async notation for methods |
| 34 | +- object safety |
| 35 | +- capture rules (https://blog.rust-lang.org/2024/09/05/impl-trait-capture-rules.html) |
| 36 | +- history and async-trait crate |
| 37 | + |
| 38 | + |
| 39 | +## Async blocks and closures |
| 40 | + |
| 41 | +- async block syntax |
| 42 | + - what it means |
| 43 | +- using an async block in a function returning a future |
| 44 | + - subtype of async method |
| 45 | +- closures |
| 46 | + - coming soon (https://github.com/rust-lang/rust/pull/132706, https://blog.rust-lang.org/inside-rust/2024/08/09/async-closures-call-for-testing.html) |
| 47 | + - async blocks in closures vs async closures |
| 48 | +- errors in async blocks |
| 49 | + - https://rust-lang.github.io/async-book/07_workarounds/02_err_in_async_blocks.html |
| 50 | + |
| 51 | +## Recursion |
| 52 | + |
| 53 | +- Allowed (relatively new), but requires some explicit boxing |
| 54 | + - forward reference to futures, pinning |
| 55 | + - https://rust-lang.github.io/async-book/07_workarounds/04_recursion.html |
| 56 | + - https://blog.rust-lang.org/2024/03/21/Rust-1.77.0.html#support-for-recursion-in-async-fn |
| 57 | + - async-recursion macro (https://docs.rs/async-recursion/latest/async_recursion/) |
| 58 | + |
| 59 | + |
| 60 | +## Lifetimes and borrowing |
| 61 | + |
| 62 | +- Mentioned the static lifetime above |
| 63 | +- Lifetime bounds on futures (`Future + '_`, etc.) |
| 64 | +- Borrowing across await points |
| 65 | +- I don't know, I'm sure there are more lifetime issues with async functions ... |
0 commit comments