@@ -264,22 +264,23 @@ public struct AsyncThrowingStream<Element, Failure: Error> {
264
264
/// `AsyncThrowingStream.Continuation` instance that it uses to provide
265
265
/// elements to the stream and terminate the stream when finished.
266
266
///
267
- /// The `AsyncThrowingStream .Continuation` received by the `build` closure is
267
+ /// The `AsyncStream .Continuation` received by the `build` closure is
268
268
/// appopriate for use in concurrent contexts. It is thread safe to send and
269
- /// finish; all calls are to the continuation are serialized, however calling
270
- /// this from multiple concurrent contexts could result in out of order
271
- /// delivery.
269
+ /// finish; all calls are to the continuation are serialized. However, calling
270
+ /// this from multiple concurrent contexts could result in out-of- order
271
+ /// delivery.
272
272
///
273
- /// The following example shows an `AsyncThrowingStream` created with this
274
- /// initializer that produces random numbers on a one-second interval. When
275
- /// a private `keepRunning` variable becomes `false`, the inner `while` loop
276
- /// exits and the stream finishes. If the random number is divisble by 5 with
277
- /// no remainder, the stream throws a `MyRandomNumberError`.
273
+ /// The following example shows an `AsyncStream` created with this
274
+ /// initializer that produces 100 random numbers on a one-second interval,
275
+ /// calling `yield(_:)` to deliver each element to the awaiting call point.
276
+ /// When the `for` loop exits and the stream finishes by calling the
277
+ /// continuation's `finish()` method. If the random number is divisble by 5
278
+ /// with no remainder, the stream throws a `MyRandomNumberError`.
278
279
///
279
280
/// let stream = AsyncThrowingStream<Int, Error>(Int.self,
280
281
/// bufferingPolicy: .bufferingNewest(5)) { continuation in
281
282
/// Task.detached {
282
- /// while (keepRunning) {
283
+ /// for _ in 0..<100 {
283
284
/// await Task.sleep(1 * 1_000_000_000)
284
285
/// let random = Int.random(in: 1...10)
285
286
/// if (random % 5 == 0) {
0 commit comments