-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Concurrency] Revise Async-
related files doc
#58930
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,9 +91,9 @@ import Swift | |
/// produces it: | ||
/// | ||
/// for await quake in QuakeMonitor.quakes { | ||
/// print ("Quake: \(quake.date)") | ||
/// print("Quake: \(quake.date)") | ||
/// } | ||
/// print ("Stream finished.") | ||
/// print("Stream finished.") | ||
/// | ||
@available(SwiftStdlib 5.1, *) | ||
public struct AsyncStream<Element> { | ||
|
@@ -272,18 +272,18 @@ public struct AsyncStream<Element> { | |
/// | ||
/// let stream = AsyncStream<Int>(Int.self, | ||
/// bufferingPolicy: .bufferingNewest(5)) { continuation in | ||
/// Task.detached { | ||
/// for _ in 0..<100 { | ||
/// await Task.sleep(1 * 1_000_000_000) | ||
/// continuation.yield(Int.random(in: 1...10)) | ||
/// } | ||
/// continuation.finish() | ||
/// Task.detached { | ||
/// for _ in 0..<100 { | ||
/// await Task.sleep(1 * 1_000_000_000) | ||
/// continuation.yield(Int.random(in: 1...10)) | ||
/// } | ||
/// continuation.finish() | ||
/// } | ||
/// } | ||
/// | ||
/// // Call point: | ||
/// for await random in stream { | ||
/// print ("\(random)") | ||
/// print(random) | ||
/// } | ||
/// | ||
public init( | ||
|
@@ -319,15 +319,13 @@ public struct AsyncStream<Element> { | |
/// the `unfolding` parameter label. | ||
/// | ||
/// let stream = AsyncStream<Int> { | ||
/// await Task.sleep(1 * 1_000_000_000) | ||
/// return Int.random(in: 1...10) | ||
/// } | ||
/// onCancel: { @Sendable () in print ("Canceled.") } | ||
/// ) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice job catching this stray There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Canceled" was correct — please change this back. Documentation follows Apple Style Guide, which calls for spelling it "canceled" and "canceling". The API naming guidelines for Cocoa (which Swift often follows) follow historical precedent of other API names, and spells it "cancelled" and "cancelling". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @amartini51 Thanks for following up! On lines 121-122 in the very same file, however, there is /// The stream finished as a result of cancellation.
case cancelled Actually, "cancelled" is being used much more than "canceled" in overall Swift repo. 🧐 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's revert this change please, so we're not making the problem worse. Someone (possibly me or @invalidname) can take another pass over the file to correct the other "cancelled" spellings in a different PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Regarding lines 121-121, Both style guides use the spelling "cancellation". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ohh, now I see. Documentation follows "canceled", while the API naming follows "cancelled". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reading my original post, I could have been clearer that there were two style guides involved here, one for code and one for docs. Sorry about that. Thanks for the fixes in this PR! |
||
/// await Task.sleep(1 * 1_000_000_000) | ||
/// return Int.random(in: 1...10) | ||
/// } onCancel: { @Sendable () in print("Canceled.") } | ||
/// | ||
/// // Call point: | ||
/// for await random in stream { | ||
/// print ("\(random)") | ||
/// print(random) | ||
/// } | ||
/// | ||
/// | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -592,4 +592,3 @@ final class _AsyncStreamCriticalStorage<Contents>: @unchecked Sendable { | |
return storage | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. This way matches the actual output on line 30.