Suspends the current task and allows other tasks to execute.
- iOS 13.0+
- macOS 10.15+
- tvOS 13.0+
- watchOS 6.0+
static func yield() async
A task can voluntarily suspend itself in the middle of a long-running operation that doesn’t contain any suspension points, to let other tasks run for a while before execution returns to this task.
If this task is the highest-priority task in the system, the executor immediately resumes execution of the same task. As such, this method isn’t necessarily a way to avoid resource starvation.