Concurrency Coordination Reports
Task Value Coordination Report
Record awaited async task completions and report the coordination state.
Task Value Coordination Report
task_value_coordination_report.swift
func produce(_ id: Int) async -> Int {
return (id + 1) * 10
}
let tasks =
var completed = 0
var total = 0
for i in 0..<tasks {
let value = await produce(i)
completed += 1
total += value
}
var status = "single"
if completed == 0 {
status = "idle"
}
if completed > 1 {
status = "batched"
}
let line = "tasks=\(tasks) completed=\(completed) total=\(total) \(status)"
print(line)
func produce(_ id: Int) async -> Int {
return (id + 1) * 10
}
let tasks =
var completed = 0
var total = 0
for i in 0..<tasks {
let value = await produce(i)
completed += 1
total += value
}
var status = "single"
if completed == 0 {
status = "idle"
}
if completed > 1 {
status = "batched"
}
let line = "tasks=\(tasks) completed=\(completed) total=\(total) \(status)"
print(line)
func produce(_ id: Int) async -> Int {
return (id + 1) * 10
}
let tasks =
var completed = 0
var total = 0
for i in 0..<tasks {
let value = await produce(i)
completed += 1
total += value
}
var status = "single"
if completed == 0 {
status = "idle"
}
if completed > 1 {
status = "batched"
}
let line = "tasks=\(tasks) completed=\(completed) total=\(total) \(status)"
print(line)
awaited task value
A coordination report can record how many async values a section awaited to completion. Each loop step awaits one `async` function call, so its value is fully resolved before the next step runs, and the completed counter advances only after the result arrives. With no tasks the section stays idle, with a single awaited task it reports one completion, and with several awaited tasks it reports a batched result. The status line summarizes the mode while the total confirms every awaited value was folded in.