Open
Description
Hi there Matt,
I'll help out with some of the more gnarly runtime topics of the guide.
I think we can have a guide about "coming from dispatch" and surprising behaviors etc.
One thing I wanted to note down for me to get back to is:
People write this code:
DispatchQueue.main.async(qos: .utility) { }
DispatchQueue.main.async(qos: .background) { }
and the equivalent with main actor:
@globalActor actor TestActor {
static let shared = TestActor()
@MainActor
func performOnMainActor() async {
Task(priority: .low) { @MainActor in
print("first")
}
Task(priority: .high) { @MainActor in
print("second")
}
}
@TestActor
func performOnTestActor() async {
Task(priority: .low) { @TestActor in
print("first")
}
Task(priority: .high) { @TestActor in
print("second")
}
}
}
So Task {} Task{}
cannot be blindly assumed to be FIFO in face of priority escalation, without knowing the exact target actor's executor.
We need to properly document what users may expect and what not.
I'll write a portion to the guide about this.
Metadata
Metadata
Assignees
Labels
No labels