Asynchronous work with compiler support.
WHAT THE MODERN MODEL PROVIDES
Asynchronous code written sequentially Structured tasks with defined lifetimes Compile-time checking of data access across threads
WHAT AN ASYNCHRONOUS FUNCTION IS
One that can suspend, allowing other work to proceed.
WHAT SUSPENSION MEANS
The thread is released, not blocked.
WHAT STRUCTURED CONCURRENCY PROVIDES
Child tasks whose lifetime is bounded by their parent, cancelled together.
WHY THAT MATTERS
Work does not outlive what started it, and cancellation propagates.
WHAT AN ACTOR IS
A type protecting its state so only one task accesses it at a time.
WHAT THAT PREVENTS
Data races, which are otherwise intermittent and extremely difficult to diagnose.
WHAT THE MAIN ACTOR DESIGNATES
Code that must run on the main thread.
WHAT TO MARK WITH IT
Anything touching the interface.
WHAT SENDABLE MEANS
A type safe to pass between concurrent contexts.
WHY THE COMPILER CARES
It refuses unsafe sharing, which is the point.
WHAT TO ALWAYS SUPPORT
Cancellation, checked at suspension points.
WHAT TO AVOID
Unstructured tasks with no ownership.