Instance Methodswift 6.0.1_Concurrency
addTaskUnlessCancelled(executorPreference:priority:operation:)
Adds a child task to the group and set it up with the passed in task executor preference, unless the group has been canceled.
- iOS
- 18.0+
- macOS
- 15.0+
- tvOS
- 18.0+
- visionOS
- 2.0+
- watchOS
- 11.0+
mutating func addTaskUnlessCancelled(executorPreference taskExecutor: (any TaskExecutor)?, priority: TaskPriority? = nil, operation: sending @escaping @isolated(any) () async -> Void) -> Bool
Parameters
- taskExecutor
The task executor that the child task should be started on and keep using. If
nil
is passed explicitly, tht parent task’s executor preference (if any), will be ignored. In order to inherit the parent task’s executor preference invokeaddTask()
without passing a value to thetaskExecutor
parameter, and it will be inherited automatically.- priority
The priority of the operation task. Omit this parameter or pass
.unspecified
to set the child task’s priority to the priority of the group.- operation
The operation to execute as part of the task group.
Returns
true
if the child task was added to the group; otherwise false
.
Other members in extension
Instance members
var isCancelled: Bool
A Boolean value that indicates whether the group was canceled.
var isEmpty: Bool
A Boolean value that indicates whether the group has any remaining tasks.
func addTask(executorPreference: (any TaskExecutor)?, priority: TaskPriority?, operation: sending
Adds a child task to the group and enqueue it on the specified executor.
func addTask(operation: sending
func addTask(priority: TaskPriority?, operation: sending
Adds a child task to the group.
func addTaskUnlessCancelled(operation: sending
Adds a child task to the group, unless the group has been canceled.
func addTaskUnlessCancelled(priority: TaskPriority?, operation: sending
Adds a child task to the group, unless the group has been canceled.
func cancelAll(
) Cancel all of the remaining tasks in the group.