FlashKeepers

Swift · College · College and University

Swift IV: Concurrency

async and await, Task, actors, Sendable, structured concurrency, MainActor and Grand Central Dispatch.

About this set

34 basic cards for College Swift. Set 4 of 4 in Swift. It opens with "What keyword allows a function to be suspended and resumed in Swift?" and "What keyword is used to call an async function?". Study it alongside the other College sets below.

34 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What keyword allows a function to be suspended and resumed in Swift?
Show answerasync
What keyword is used to call an async function?
Show answerawait
What is the purpose of structured concurrency?
Show answerTo ensure all child tasks complete before a scope exits
What is a Task in Swift concurrency?
Show answerA lightweight unit of concurrent work that runs independently
What is an actor in Swift?
Show answerA reference type that protects mutable state with serial access
What protocol makes a type safe to share across actors?
Show answerSendable
What is MainActor?
Show answerAn actor that guarantees code runs on the main thread
What is Grand Central Dispatch?
Show answerA low-level API for managing concurrent work using queues
How do actors prevent data races?
Show answerBy ensuring only one task accesses mutable state at a time
What does Task { } do?
Show answerCreates a new concurrent task that runs independently
How do you make a custom type Sendable?
Show answerHave it conform to the Sendable marker protocol
What happens when you await an async function?
Show answerThe current task suspends until the function returns
What is a suspension point in Swift concurrency?
Show answerA location where a task pauses and another task can resume
What is the main benefit of structured concurrency?
Show answerAutomatic resource cleanup and cancellation propagation
When should you use MainActor annotation?
Show answerFor code that must execute on the main thread

19 more cards in the app

Study this set free