iOS

Concurrency & async/await

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

26 mülakat soruları·
Senior
1

What is an async function in Swift?

Cevap

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?

Cevap

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?

Cevap

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 mülakat soruları

Bir sonraki mülakatın için iOS'de uzmanlaş

Tüm sorulara, flashcards'a, teknik testlere, code review alıştırmalarına ve mülakat simülatörlerine eriş.

Ücretsiz başla