Skip to content

Commit ba14cf6

Browse files
author
Chris Adamson
committed
Apply some doc comment feedback from @phausler.
1 parent e6a2e17 commit ba14cf6

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

stdlib/public/Concurrency/AsyncStream.swift

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,12 +129,14 @@ public struct AsyncStream<Element> {
129129
///
130130
/// This value reprsents the successful enqueueing of an element, whether
131131
/// the stream buffers the element or delivers it immediately to a pending
132-
/// call to `next()`. The associated value `remaining` indicates the
133-
/// number of remaining slots in the buffer at the point in time of
134-
/// yielding.
132+
/// call to `next()`. The associated value `remaining` is a hint that
133+
/// indicates the number of remaining slots in the buffer at the time of
134+
/// the `yield` call.
135135
///
136-
/// > Note: Acting on the remaining count is valid only when calls to
137-
/// yield are mutually exclusive.
136+
/// > Note: From a thread safety viewpoint, `remaining` is a lower bound
137+
/// on the number of remaining slots. This is because a subsequent call
138+
/// that uses the `remaining` value could race on the consumption of
139+
/// values from the stream.
138140
case enqueued(remaining: Int)
139141

140142
/// The stream didn't enqueue the element due to a full buffer.
@@ -153,17 +155,20 @@ public struct AsyncStream<Element> {
153155

154156
/// A strategy that handles exhaustion of a buffer’s capacity.
155157
public enum BufferingPolicy {
156-
/// Continue to add to the buffer, treating its capacity as infinite.
158+
/// Continue to add to the buffer, without imposing a limit on the number
159+
/// of buffered elements.
157160
case unbounded
158161

159162
/// When the buffer is full, discard the newly received element.
160163
///
161-
/// This strategy enforces keeping the specified number of oldest values.
164+
/// This strategy enforces keeping at most the specified number of oldest
165+
/// values.
162166
case bufferingOldest(Int)
163167

164168
/// When the buffer is full, discard the oldest element in the buffer.
165169
///
166-
/// This strategy enforces keeping the specified number of newest values.
170+
/// This strategy enforces keeping at most the specified number of newest
171+
/// values.
167172
case bufferingNewest(Int)
168173
}
169174

@@ -180,7 +185,7 @@ public struct AsyncStream<Element> {
180185
/// result's element.
181186
///
182187
/// This can be called more than once and returns to the caller immediately
183-
/// without blocking for any awaiting consuption from the iteration.
188+
/// without blocking for any awaiting consumption from the iteration.
184189
@discardableResult
185190
public func yield(_ value: __owned Element) -> YieldResult {
186191
storage.yield(value)
@@ -206,7 +211,8 @@ public struct AsyncStream<Element> {
206211
/// Canceling an active iteration invokes the `onTermination` callback
207212
/// first, then resumes by yielding `nil`. This means that you can perform
208213
/// needed cleanup in the cancellation handler. After reaching a terminal
209-
/// state, the `AsyncStream` disposes of the callback.
214+
/// state as a result of cancellation, the `AsyncStream` sets the callback
215+
/// to `nil`.
210216
public var onTermination: (@Sendable (Termination) -> Void)? {
211217
get {
212218
return storage.getOnTermination()
@@ -224,10 +230,10 @@ public struct AsyncStream<Element> {
224230
///
225231
/// - Parameter elementType: The type of element the `AsyncStream`
226232
/// produces.
227-
/// - Parameter limit: The maximum number of elements to hold in the buffer.
228-
/// By default, this value is unlimited. Use a
229-
/// `Continuation.BufferingPolicy` to buffer a specified number of oldest
230-
/// or newest elements.
233+
/// - Parameter bufferingPolicy: A `Continuation.BufferingPolicy` value to
234+
/// set the stream's buffering behavior. By default, the stream buffers an
235+
/// unlimited number of elements. You can also set the policy to buffer a
236+
/// specified number of oldest or newest elements.
231237
/// - Parameter build: A custom closure that yields values to the
232238
/// `AsyncStream`. This closure receives a `AsyncStream.Continuation`
233239
/// instance that it uses to provide elements to the stream and terminate the
@@ -280,9 +286,9 @@ public struct AsyncStream<Element> {
280286
/// Use this convenience initializer when you have an asychronous function
281287
/// that can produce elements for the stream, and don't want to invoke
282288
/// a continuation manually. This initializer "unfolds" your closure into
283-
/// a full-blown asynchronous stream. The created stream handles adherence to
284-
/// the `AsyncSequence` protocol automatically, including termination (whether
285-
/// by cancellation or by returning `nil` from the closure to finish
289+
/// a full-blown asynchronous stream. The created stream handles conformance
290+
/// to the `AsyncSequence` protocol automatically, including termination
291+
/// (whether by cancellation or by returning `nil` from the closure to finish
286292
/// iteration).
287293
///
288294
/// The following example shows an `AsyncStream` created with this

stdlib/public/Concurrency/AsyncThrowingStream.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ public struct AsyncThrowingStream<Element, Failure: Error> {
206206
/// result's element.
207207
///
208208
/// This can be called more than once and returns to the caller immediately
209-
/// without blocking for any awaiting consuption from the iteration.
209+
/// without blocking for any awaiting consumption from the iteration.
210210
@discardableResult
211211
public func yield(_ value: __owned Element) -> YieldResult {
212212
storage.yield(value)

0 commit comments

Comments
 (0)