@@ -149,6 +149,7 @@ public struct AsyncStream<Element> {
149
149
150
150
/// A strategy that handles exhaustion of a buffer’s capacity.
151
151
public enum BufferingPolicy {
152
+ /// Continue to add to the buffer, treating its capacity as infinite.
152
153
case unbounded
153
154
154
155
/// When the buffer is full, discard the newly received element.
@@ -191,14 +192,15 @@ public struct AsyncStream<Element> {
191
192
storage. finish ( )
192
193
}
193
194
194
- /// A callback to invoke when canceling iteration of a AsyncStream.
195
+ /// A callback to invoke when canceling iteration of an asynchronous
196
+ /// stream.
195
197
///
196
- /// If an `onTermination` callback is set, using task cancelation to
197
- /// terminate iteration of a AsyncStream results in a call to this
198
+ /// If an `onTermination` callback is set, using task cancellation to
199
+ /// terminate iteration of a ` AsyncStream` results in a call to this
198
200
/// callback.
199
201
///
200
202
/// Cancelling an active iteration invokes the `onTermination` callback
201
- /// first, then resumes by yeilding `nil`. This means that you can perform
203
+ /// first, then resumes by yielding `nil`. This means that you can perform
202
204
/// needed cleanup in the cancellation handler. After reaching a terminal
203
205
/// state, the `AsyncStream` disposes of the callback.
204
206
public var onTermination : ( @Sendable ( Termination ) -> Void ) ? {
@@ -223,9 +225,9 @@ public struct AsyncStream<Element> {
223
225
/// `Continuation.BufferingPolicy` to buffer a specified number of oldest
224
226
/// or newest elements.
225
227
/// - Parameter build: A custom closure that yields values to the
226
- /// `AsyncStream`. This closure receives a `AsyncStream.Continuation` object
227
- /// that it uses to provide elements to the stream and terminate the stream
228
- /// when finished.
228
+ /// `AsyncStream`. This closure receives a `AsyncStream.Continuation`
229
+ /// instance that it uses to provide elements to the stream and terminate the
230
+ /// stream when finished.
229
231
///
230
232
/// The `AsyncStream.Contuation` received by the `build` closure is appopriate
231
233
/// for use in concurrent contexts. It is thread safe to send and finish; all
@@ -235,7 +237,7 @@ public struct AsyncStream<Element> {
235
237
/// The following example shows an `AsyncStream` created with this
236
238
/// initializer that produces random numbers on a one-second interval. When
237
239
/// a private `keepRunning` variable becomes `false`, the inner `while` loop
238
- ///
240
+ /// exits and the stream finishes.
239
241
///
240
242
/// let stream = AsyncStream<Int>(
241
243
/// Int.self, bufferingPolicy: .bufferingNewest(5)) { continuation in
@@ -345,7 +347,8 @@ extension AsyncStream: AsyncSequence {
345
347
}
346
348
}
347
349
348
- /// Constructs an iterator.
350
+ /// Creates the asynchronous iterator that produces elements of this
351
+ /// asynchronous sequence.
349
352
public func makeAsyncIterator( ) -> Iterator {
350
353
return Iterator ( produce: produce)
351
354
}
@@ -381,7 +384,7 @@ extension AsyncStream.Continuation {
381
384
/// - Returns: A `YieldResult` indicating the success or failure of the
382
385
/// yield operation.
383
386
///
384
- /// Use this method with `AsyncStream` instances whose element type is
387
+ /// Use this method with `AsyncStream` instances whose `Element` type is
385
388
/// `Void`. In this case, the `yield()` call simply unblocks the awaiting
386
389
/// iteration; there is no value to return.
387
390
///
0 commit comments