You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -180,9 +180,9 @@ The child-task created to initialize the `async let` by default runs on the glob
180
180
181
181
> Customizing the execution context of async lets is a future direction we are likely to explore with the introduction of Custom Executors.
182
182
183
-
The initializer of the `async let` can be thought of as a closure that runs the code contained within it in a separate task, very much like the explicit `group.async { <work here/> }` API of task groups.
183
+
The initializer of the `async let` can be thought of as a closure that runs the code contained within it in a separate task, very much like the explicit `group.addTask { <work here/> }` API of task groups.
184
184
185
-
Similarly to the `group.async()` function, the closure is `@Sendable` and `nonisolated`, meaning that it cannot access non-sendable state of the enclosing context. For example, it will result in a compile-time error, preventing a potential race condition, for a `async let` initializer to attempt mutating a closed-over variable:
185
+
Similarly to the `group.addTask()` function, the closure is `@Sendable` and `nonisolated`, meaning that it cannot access non-sendable state of the enclosing context. For example, it will result in a compile-time error, preventing a potential race condition, for a `async let` initializer to attempt mutating a closed-over variable:
186
186
187
187
```swift
188
188
var localText: [String] =...
@@ -372,7 +372,7 @@ This is the same as spawning a number of child-tasks in a task group, and not co
372
372
373
373
```swift
374
374
tryawaitwithThrowingTaskGroup(of: Int.self) { group in
375
-
group.async { throwBoom() }
375
+
group.addTask { throwBoom() }
376
376
377
377
return0// we didn't care about the child-task at all(!)
378
378
} // returns 0
@@ -414,7 +414,7 @@ Cancellation propagates recursively through the task hierarchy from parent to ch
414
414
415
415
Because tasks spawned by `async let` are child tasks, they naturally participate in their parent's cancellation.
416
416
417
-
Cancellation of the parent task means that the context in which the `async let` declarations exist is cancelled, and any tasks created by those declarations will be cancelled as well. Because cancellation in Swift is co-operative, it does not prevent the spawning of tasks, however tasks spawned from a cancelled context are *immediately* marked as cancelled. This exhibits the same semantics as `TaskGroup.async` which, when used from an already cancelled task, _will_ spawn more child-tasks, however they will be immediately created as cancelled tasks — which they can inspect by calling `Task.isCancelled`.
417
+
Cancellation of the parent task means that the context in which the `async let` declarations exist is cancelled, and any tasks created by those declarations will be cancelled as well. Because cancellation in Swift is co-operative, it does not prevent the spawning of tasks, however tasks spawned from a cancelled context are *immediately* marked as cancelled. This exhibits the same semantics as `TaskGroup.addTask` which, when used from an already cancelled task, _will_ spawn more child-tasks, however they will be immediately created as cancelled tasks — which they can inspect by calling `Task.isCancelled`.
0 commit comments