Concurrency Concepts
Awaited Values
Multiple async calls can be awaited and then combined with ordinary arithmetic.
Await two calls
awaited_values.swift
func score(_ value: Int) async -> Int {
return value + 1
}
let base =
let first = await score(base)
let second = await score(base + 2)
let total = first + second
let message = "total=\(total)"
print(message)
func score(_ value: Int) async -> Int {
return value + 1
}
let base =
let first = await score(base)
let second = await score(base + 2)
let total = first + second
let message = "total=\(total)"
print(message)
func score(_ value: Int) async -> Int {
return value + 1
}
let base =
let first = await score(base)
let second = await score(base + 2)
let total = first + second
let message = "total=\(total)"
print(message)
awaited value
Awaiting each async call stores normal values that later statements can reuse.