@@ -1211,6 +1211,29 @@ extension TaskGroup: AsyncSequence {
1211
1211
return element
1212
1212
}
1213
1213
1214
+ /// Advances to and returns the result of the next child task.
1215
+ ///
1216
+ /// The elements returned from this method
1217
+ /// appear in the order that the tasks *completed*,
1218
+ /// not in the order that those tasks were added to the task group.
1219
+ /// After this method returns `nil`,
1220
+ /// this iterator is guaranteed to never produce more values.
1221
+ ///
1222
+ /// For more information about the iteration order and semantics,
1223
+ /// see `TaskGroup.next()`.
1224
+ ///
1225
+ /// - Returns: The value returned by the next child task that completes,
1226
+ /// or `nil` if there are no remaining child tasks,
1227
+ @available ( SwiftStdlib 6 . 0 , * )
1228
+ public mutating func next( isolation actor : isolated ( any Actor ) ? ) async -> Element ? {
1229
+ guard !finished else { return nil }
1230
+ guard let element = await group. next ( isolation: actor ) else {
1231
+ finished = true
1232
+ return nil
1233
+ }
1234
+ return element
1235
+ }
1236
+
1214
1237
public mutating func cancel( ) {
1215
1238
finished = true
1216
1239
group. cancelAll ( )
@@ -1324,7 +1347,7 @@ extension ThrowingTaskGroup: AsyncSequence {
1324
1347
public mutating func next( isolation actor : isolated ( any Actor ) ? ) async throws ( Failure) -> Element ? {
1325
1348
guard !finished else { return nil }
1326
1349
do {
1327
- guard let element = try await group. next ( ) else {
1350
+ guard let element = try await group. next ( isolation : actor ) else {
1328
1351
finished = true
1329
1352
return nil
1330
1353
}
0 commit comments