Skip to content

Instantly share code, notes, and snippets.

@laevandus
Created March 5, 2023 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save laevandus/38d50fca70322539d60c5f6d90ab6870 to your computer and use it in GitHub Desktop.
Save laevandus/38d50fca70322539d60c5f6d90ab6870 to your computer and use it in GitHub Desktop.
let imageDatas = try await withThrowingTaskGroup(of: Data.self, returning: [Data].self) { group in
imageIdentifiers.forEach { imageIdentifier in
group.addTask {
return try await ImageProcessor.process(identifier: imageIdentifier)
}
}
var results = [Data]()
for try await imageData in group {
results.append(imageData)
}
return results
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment