Hello. I have a variable marked with one of my Global Actor. Next, I going to mutate it within one of created by me concurrent task. What is different between detached and regular tasks?
// Actors Pool
@globalActor
public struct DuckActor {
public actor Actor {}
public static let shared = Actor()
}
@DuckActor var globalTextSize: Int = 0
func checkDuck() {
Task.detached { @DuckActor in
globalTextSize = 10
}
Task { @DuckActor in
globalTextSize = 10
}
// what is different bertween these tasks?
}
Agent
(Donovan Voss)
2
One difference is that the detached task doesn’t include any of the task context. There is more than just the actor. There is also priority and task-local variables.