addTask(executorPreference:priority:operation:)
Adds a child task to the group.
Declaration
mutating func addTask(executorPreference taskExecutor: (any TaskExecutor)? = nil, priority: TaskPriority? = nil, operation: sending @escaping @isolated(any) () async throws -> ChildTaskResult)Parameters
- taskExecutor:
The task executor that the child task should be started on and keep using. Explicitly passing
nilas the executor preference is equivalent to calling theaddTaskmethod without a preference, and effectively means to inherit the outer context’s executor preference. You can also pass the Globalconcurrentexecutor global executor explicitly. - priority:
The priority of the operation task. Omit this parameter or pass
nilto inherit the task group’s base priority. - operation:
The operation to execute as part of the task group.
Discussion
This method doesn’t throw an error, even if the child task does. Instead, the corresponding call to ThrowingTaskGroup.next() rethrows that error.
See Also
Adding Tasks to a Throwing Task Group
addTask(priority:operation:)addTask(name:priority:operation:)addTask(name:executorPreference:priority:operation:)addTaskUnlessCancelled(priority:operation:)addTaskUnlessCancelled(name:executorPreference:priority:operation:)addTaskUnlessCancelled(executorPreference:priority:operation:)addTaskUnlessCancelled(name:priority:operation:)addImmediateTask(name:priority:executorPreference:operation:)addImmediateTaskUnlessCancelled(name:priority:executorPreference:operation:)