Is it possible to get the current task from within an async function?
UnsafeCurrentTask. The documentation of
[...] use the
UnsafeCurrentTaskto access an instance of
Taskthat you can store long-term and interact with outside of the closure body. [...]
However, it looks like this property is not available (Xcode 13 Beta 3) and I think it is also not mentioned in the Proposal.
Context: I want to get the current task during the execution of the closure that I pass to
Task.init(priority:operation:) to be able to cancel the current task later.