somu
(somu)
1
Hi,
Questions
- How I can get determine the current priority of the task. (Task.currentPriority). I don't know how to make sense out of it, printing prints the rawValue.
- What is the order of priority (I couldn't find documentation on the order, lowest to highest)?
My attempt:
Is there a better way to determine the priority?
Task {
print("current priority = \(Task.currentPriority)")
switch Task.currentPriority {
case .userInitiated:
print("userInitiated")
case .high:
print("high")
case .medium:
print("medium")
case .low:
print("low")
case .background:
print("background")
default:
print("something else")
}
}
bbrk24
2
There's actually only four priority levels -- userInitiated is just an alias for high -- and the raw values correspond to the priority order:
-
high = 25
-
medium = 21
-
low = 17
-
background = 9
I played around with raw values in-between these options, and while it does let you construct them, trying to spawn a task with a priority of e.g. 11 will crash at runtime.
1 Like
somu
(somu)
3
@bbrk24 Thanks a lot for the clarification.
Is there any documentation for this? I wish this was made more explicit.
ktoso
(Konrad 'ktoso' Malawski 🐟🏴☠️)
4
1 Like
somu
(somu)
5
@ktoso Thanks a lot!!! Really appreciate the effort!
1 Like