-
-
Save laevandus/3c19ffd71b56bffe97e837047afa20bd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let imageDatas = await withTaskGroup(of: Data?.self, returning: [Data].self) { group in | |
imageIdentifiers.forEach { imageIdentifier in | |
group.addTask { | |
do { | |
return try await ImageProcessor.process(identifier: imageIdentifier) | |
} catch { | |
return nil | |
} | |
} | |
} | |
var results = [Data]() | |
for await imageData in group.compactMap({ $0 }) { | |
results.append(imageData) | |
} | |
return results | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment