async and await, Task, actors, Sendable, structured concurrency, MainActor and Grand Central Dispatch.
34 cards · basic cards · AI-written, checked twice. Edit anything.
- What keyword allows a function to be suspended and resumed in Swift?
Show answer
async
- What keyword is used to call an async function?
Show answer
await
- What is the purpose of structured concurrency?
Show answer
To ensure all child tasks complete before a scope exits
- What is a Task in Swift concurrency?
Show answer
A lightweight unit of concurrent work that runs independently
- What is an actor in Swift?
Show answer
A reference type that protects mutable state with serial access
- What protocol makes a type safe to share across actors?
Show answer
Sendable
- What is MainActor?
Show answer
An actor that guarantees code runs on the main thread
- What is Grand Central Dispatch?
Show answer
A low-level API for managing concurrent work using queues
- How do actors prevent data races?
Show answer
By ensuring only one task accesses mutable state at a time
- What does Task { } do?
Show answer
Creates a new concurrent task that runs independently
- How do you make a custom type Sendable?
Show answer
Have it conform to the Sendable marker protocol
- What happens when you await an async function?
Show answer
The current task suspends until the function returns
- What is a suspension point in Swift concurrency?
Show answer
A location where a task pauses and another task can resume
- What is the main benefit of structured concurrency?
Show answer
Automatic resource cleanup and cancellation propagation
- When should you use MainActor annotation?
Show answer
For code that must execute on the main thread