Skip to content

Commit d88b799

Browse files
authored
Merge pull request swiftlang#76079 from hborla/async-stream-sendable
[Concurrency] Add missing `Sendable` conformances to nested value types in `Async{Throwing}Stream`.
2 parents d8db750 + ee4c034 commit d88b799

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

stdlib/public/Concurrency/AsyncStream.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public struct AsyncStream<Element> {
113113
/// A type that indicates how the stream terminated.
114114
///
115115
/// The `onTermination` closure receives an instance of this type.
116-
public enum Termination {
116+
public enum Termination: Sendable {
117117

118118
/// The stream finished as a result of calling the continuation's
119119
/// `finish` method.
@@ -159,7 +159,7 @@ public struct AsyncStream<Element> {
159159
}
160160

161161
/// A strategy that handles exhaustion of a buffer’s capacity.
162-
public enum BufferingPolicy {
162+
public enum BufferingPolicy: Sendable {
163163
/// Continue to add to the buffer, without imposing a limit on the number
164164
/// of buffered elements.
165165
case unbounded
@@ -471,6 +471,10 @@ extension AsyncStream {
471471

472472
@available(SwiftStdlib 5.1, *)
473473
extension AsyncStream: @unchecked Sendable where Element: Sendable { }
474+
475+
@available(SwiftStdlib 5.1, *)
476+
extension AsyncStream.Continuation.YieldResult: Sendable where Element: Sendable { }
477+
474478
#else
475479
@available(SwiftStdlib 5.1, *)
476480
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")

stdlib/public/Concurrency/AsyncThrowingStream.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public struct AsyncThrowingStream<Element, Failure: Error> {
133133
/// A type that indicates how the stream terminated.
134134
///
135135
/// The `onTermination` closure receives an instance of this type.
136-
public enum Termination {
136+
public enum Termination: Sendable {
137137

138138
/// The stream finished as a result of calling the continuation's
139139
/// `finish` method.
@@ -184,7 +184,7 @@ public struct AsyncThrowingStream<Element, Failure: Error> {
184184
}
185185

186186
/// A strategy that handles exhaustion of a buffer’s capacity.
187-
public enum BufferingPolicy {
187+
public enum BufferingPolicy: Sendable {
188188
/// Continue to add to the buffer, treating its capacity as infinite.
189189
case unbounded
190190

@@ -517,6 +517,10 @@ extension AsyncThrowingStream {
517517

518518
@available(SwiftStdlib 5.1, *)
519519
extension AsyncThrowingStream: @unchecked Sendable where Element: Sendable { }
520+
521+
@available(SwiftStdlib 5.1, *)
522+
extension AsyncThrowingStream.Continuation.YieldResult: Sendable where Element: Sendable { }
523+
520524
#else
521525
@available(SwiftStdlib 5.1, *)
522526
@available(*, unavailable, message: "Unavailable in task-to-thread concurrency model")

0 commit comments

Comments
 (0)