Today, TaskGroup.addTask
takes an escaping closure, which means it cannot capture non-escaping values. This is necessary because TaskGroup
itself can escape. (It's not supposed to be escaped, but there's no compiler enforcement of this today.)
After talking with some of the Concurrency experts, it seems there is interest in using ~Escapable
to close this hole and improve other aspects of the Concurrency API.
I've updated the proposal Future Directions to call this out as something that we'd like to do someday. It's not something I want to try to implement in this proposal. Since adding ~Escapable
to an existing type is not ABI stable, it will require some careful thought about how to best evolve the Concurrency APIs to avoid breaking existing code.