When you create a detached task with detached(priority:operation:) but leave priority set to nil, what priority does iOS assign?
For example, suppose a photo output handler calls an actor like this:
class PhotoViewController: UIViewController {
func photoOutput(_ photoOutput: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
let photoWithContext = someCallToMainActor(photo)
Task.detached {
let result = async someCallToAnotherActor(photoWithContext)
async anotherCallToMainActor(result)
}
}
}
The docs for detached(priority:operation:) say about priority, “You need to handle these considerations manually with a detached task.” Since the detached task isn’t a child task, I don’t get the feature that, “Child tasks inherit the parent task’s priority”.
I realize that I can specify the priority explicitly. Still, there presumably is a reason that detached(priority:operation:) allows priority to be nil, and one would expect a well defined semantic. Are there any rules that govern the detached task’s priority?
For child tasks the priority of task is inherited from parent task, and for both detached task and a parent task if priority provided is
nil,TaskPriority.mediumis used as priority.