iOS

Concurrency & async/await

async/await, Task, actors, MainActor, structured concurrency, task groups, cancellation

26 perguntas de entrevistaยท
Senior
1

What is an async function in Swift?

Resposta

An async function is one that can suspend and resume without blocking the thread. It uses the async keyword to indicate it can await asynchronous operations with await. The Swift compiler automatically generates code to manage the suspension state, allowing other tasks to execute during waits.

2

What is the role of the await keyword in Swift?

Resposta

The await keyword marks a potential suspension point where a function can be suspended while waiting for an asynchronous operation result. It signals to the compiler and Swift runtime that the execution context may change at this point, allowing the system to execute other tasks during the wait. This is fundamental to Swift's cooperative concurrency model.

3

What is a Task in Swift concurrency?

Resposta

A Task is a unit of asynchronous work that represents an independent executing operation. It encapsulates an asynchronous operation and manages its lifecycle, enabling async code to be launched from a synchronous context.

4

What is the difference between Task and Task.detached?

5

How to use async let for concurrency?

+23 perguntas de entrevista

Domine iOS para sua proxima entrevista

Acesse todas as perguntas, flashcards, testes tecnicos, exercicios de code review e simuladores de entrevista.

Comece gratis