My hope would be for something along these lines:

func createDownloadTasks(for urls: [URL]) -> [async Data] {
    return urls.map { url in async downloadResource(url) }
}
func await(all tasks: [async Data]) async -> [Data] {
    return tasks.map { task in await task }
}

-Thorsten


> Am 11.09.2017 um 22:49 schrieb Adam Kemp via swift-evolution 
> <[email protected]>:
> 
> Sorry, I was away for a while so I couldn’t respond to this right away.
> 
>> On Aug 29, 2017, at 12:29 AM, Jonathan Hull <[email protected]> wrote:
>> 
>> If you are asking about how ‘async’ (which defers ‘await’) composes, it 
>> actually composes completely naturally… and I believe that should be 
>> provable.  
> 
> Can you show me specifically how that would work, then? For instance, let’s 
> say that we want to start N (unknown, i.e., not constant) async requests and 
> then, only once all of them have begun, wait for all them to complete. What 
> would that code look like?
> 
> Extending that example, let’s say we wanted to use one function to start the 
> N requests and then use a different function to wait on them. What would be 
> the signatures of these functions?
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected]
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to