Looking at [Concurrency] Structured concurrency, I guess the Objective-C -> Swift import could work by having the progress being imported as a property of the underlying Task
.
For instance, if we had the method described before, you could do:
async let result = try doSoethingThatTakesALongTime()
let progress = $result.progress // access the underlying `Task` and extract the progress from it
For the case of the @objc
method implemented in swift, the progress could be generated by the system and made accessible, for instance using a single on Task
:
func doSoethingThatTakesALongTime() throws async -> MyResult
{
let progress = Task.current.progress // get a progress that the method can update, attach children, ...
}
or by passing it as a parameter of the method:
func doSoethingThatTakesALongTime(progress: Progress) throws async -> MyResult
{
}
What do you think?