Skip to content

Commit 38b652d

Browse files
committed
Add "async" aliases to task group "spawn" operations
1 parent 220e29d commit 38b652d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

stdlib/public/Concurrency/TaskGroup.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ public struct TaskGroup<ChildTaskResult> {
230230
spawn(priority: optPriority, operation: operation)
231231
}
232232

233+
@_alwaysEmitIntoClient
234+
public mutating func async(
235+
priority: Task.Priority? = nil,
236+
operation: __owned @Sendable @escaping () async -> ChildTaskResult
237+
) {
238+
spawn(priority: priority, operation: operation)
239+
}
240+
233241
/// Add a child task to the group.
234242
///
235243
/// ### Error handling
@@ -280,6 +288,14 @@ public struct TaskGroup<ChildTaskResult> {
280288
return spawnUnlessCancelled(priority: optPriority, operation: operation)
281289
}
282290

291+
@_alwaysEmitIntoClient
292+
public mutating func asyncUnlessCancelled(
293+
priority: Task.Priority? = nil,
294+
operation: __owned @Sendable @escaping () async -> ChildTaskResult
295+
) -> Bool {
296+
spawnUnlessCancelled(priority: priority, operation: operation)
297+
}
298+
283299
/// Add a child task to the group.
284300
///
285301
/// ### Error handling
@@ -502,6 +518,14 @@ public struct ThrowingTaskGroup<ChildTaskResult, Failure: Error> {
502518
return spawn(priority: optPriority, operation: operation)
503519
}
504520

521+
@_alwaysEmitIntoClient
522+
public mutating func async(
523+
priority: Task.Priority? = nil,
524+
operation: __owned @Sendable @escaping () async throws -> ChildTaskResult
525+
) {
526+
spawn(priority: priority, operation: operation)
527+
}
528+
505529
/// Spawn, unconditionally, a child task in the group.
506530
///
507531
/// ### Error handling
@@ -553,6 +577,14 @@ public struct ThrowingTaskGroup<ChildTaskResult, Failure: Error> {
553577
return spawnUnlessCancelled(priority: optPriority, operation: operation)
554578
}
555579

580+
@_alwaysEmitIntoClient
581+
public mutating func asyncUnlessCancelled(
582+
priority: Task.Priority? = nil,
583+
operation: __owned @Sendable @escaping () async throws -> ChildTaskResult
584+
) -> Bool {
585+
spawnUnlessCancelled(priority: priority, operation: operation)
586+
}
587+
556588
/// Add a child task to the group.
557589
///
558590
/// ### Error handling

0 commit comments

Comments
 (0)