Skip to content
academia.sh

Course Advanced

Concurrency and Asynchronous Rust

Published Updated

By the end of this course

Start course

01

Threads

A job moved to a separate unit of execution and waited on to finish, message passing built on the transfer of ownership, which types can cross a boundary written into the type itself, shared state protected with a lock, and the guarantee a lock-free counter gives through memory ordering.

  1. 01 Thread Creation The course's opening lesson runs the full measurement core: of thirteen units, 5 advanced on their own, 3 when polled, 3 when something else finished; 2 never advanced at all — thread spawning and joining establish this distribution's on-its-own and when-something-else-finishes classes.
  2. 02 Message Passing with Channels The side waiting for word from a channel advances when something else finishes; the side that builds and sends the word advances on its own. The sent value's ownership moves into the channel and can no longer be used on the sending side.
  3. 03 Thread Safety in the Type System Whether a value can cross a thread boundary is a condition written into the type: a design that can cross is actually carried across and its record is read, but the type permitting this does not show that a shared computation will give the same result as an independent assumption would.
  4. 04 Mutex and Read-Write Lock The side holding a mutex advances on its own, the side waiting for it advances when something else finishes; this order is made deterministic with a channel handshake, and the read side of a read-write lock departs from a mutex by allowing more than one reader at the same time.
  5. 05 Atomic Operations and Memory Ordering A lock-free counter advances without waiting, needing no one; the same total of increments is carried out both with a mutex and with atomic operations, and the two methods give exactly the same result — the difference is not in the result, but in whether a waiting side exists.

02

Asynchronous Programming

A task is a lazy value that never advances on its own: suspension points are written visibly in the source, the executor that advances a task stays outside the language itself, waiting on input and output is modeled as suspension, and dropping a task is how cancellation is established.

  1. 01 Futures A future is a lazy value that advances only when polled, not the moment it is constructed: of two tasks built from the same source, the one handed to the executor writes a record to the ledger, while the one withheld from the executor leaves no trace.
  2. 02 `async`/`await` Suspension points are written visibly in the source: a body that pauses once completes in two polls, a body that is ready immediately completes in one poll, and an outer body waiting on an inner future advances when something else finishes.
  3. 03 Executors Rust's standard library has no executor; the course's own two hand-written executor implementations produce identical poll counts when they run the same task — an executor adds nothing to a task's body, it only decides when to poll it.
  4. 04 Asynchronous Input/Output Suspension while waiting on input or output is modeled by a resource that returns Pending until it is ready, not by a real network or file; what is measured is how many polls it takes to complete, not the resource's time to become ready.
  5. 05 Cancellation and Timeouts The course's closing lesson measures the cancellation established by dropping a task: a dropped task is never polled again and falls into the not-at-all class; a timeout, too, is modeled not by a duration but by an exhausted poll budget.

Final exam

Concurrency and Asynchronous Rust — Final Exam

In preparation

This course's question bank is not complete yet. The exam opens here automatically once enough questions are added.

Start typing to search.

↑↓ ↵ Esc navigate · open · close