Skip to content

Commit 5d36643

Browse files
authored
Merge pull request #81126 from ktoso/wip-inlinable-for-hashable-asyncstream
[Concurrency] Hashable funcs should be inlinable for AsyncStream
2 parents 80527f0 + 99d95aa commit 5d36643

File tree

6 files changed

+53
-0
lines changed

6 files changed

+53
-0
lines changed

stdlib/public/Concurrency/AsyncStream.swift

+4
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ public struct AsyncStream<Element> {
177177
case bufferingNewest(Int)
178178
}
179179

180+
@usableFromInline
180181
let storage: _Storage
181182

182183
/// Resume the task awaiting the next iteration point by having it return
@@ -477,14 +478,17 @@ extension AsyncStream.Continuation.YieldResult: Sendable where Element: Sendable
477478

478479
@available(SwiftStdlib 6.2, *)
479480
extension AsyncStream.Continuation: Hashable {
481+
@inlinable
480482
@available(SwiftStdlib 6.2, *)
481483
public func hash(into hasher: inout Hasher) {
482484
return hasher.combine(ObjectIdentifier(storage))
483485
}
486+
@inlinable
484487
@available(SwiftStdlib 6.2, *)
485488
public var hashValue: Int {
486489
return _hashValue(for: self)
487490
}
491+
@inlinable
488492
@available(SwiftStdlib 6.2, *)
489493
public static func == (lhs: Self, rhs: Self) -> Bool {
490494
return lhs.storage === rhs.storage

stdlib/public/Concurrency/AsyncStreamBuffer.swift

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ func _unlock(_ ptr: UnsafeRawPointer)
5555
@available(SwiftStdlib 5.1, *)
5656
extension AsyncStream {
5757
@safe
58+
@usableFromInline
5859
internal final class _Storage: @unchecked Sendable {
5960
typealias TerminationHandler = @Sendable (Continuation.Termination) -> Void
6061

@@ -281,6 +282,7 @@ extension AsyncStream {
281282
@available(SwiftStdlib 5.1, *)
282283
extension AsyncThrowingStream {
283284
@safe
285+
@usableFromInline
284286
internal final class _Storage: @unchecked Sendable {
285287
typealias TerminationHandler = @Sendable (Continuation.Termination) -> Void
286288
enum Terminal {

stdlib/public/Concurrency/AsyncThrowingStream.swift

+4
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ public struct AsyncThrowingStream<Element, Failure: Error> {
199199
case bufferingNewest(Int)
200200
}
201201

202+
@usableFromInline
202203
let storage: _Storage
203204

204205
/// Resume the task awaiting the next iteration point by having it return
@@ -523,14 +524,17 @@ extension AsyncThrowingStream.Continuation.YieldResult: Sendable where Element:
523524

524525
@available(SwiftStdlib 6.2, *)
525526
extension AsyncThrowingStream.Continuation: Hashable {
527+
@inlinable
526528
@available(SwiftStdlib 6.2, *)
527529
public func hash(into hasher: inout Hasher) {
528530
return hasher.combine(ObjectIdentifier(storage))
529531
}
532+
@inlinable
530533
@available(SwiftStdlib 6.2, *)
531534
public var hashValue: Int {
532535
return _hashValue(for: self)
533536
}
537+
@inlinable
534538
@available(SwiftStdlib 6.2, *)
535539
public static func == (lhs: Self, rhs: Self) -> Bool {
536540
return lhs.storage === rhs.storage

test/abi/macOS/arm64/concurrency.swift

+18
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,21 @@ Added: _swift_task_dealloc_through
416416

417417
// SwiftSettings
418418
Added: _$ss12SwiftSettingVsE16defaultIsolationyABScA_pXpSgFZ
419+
420+
// Hashable for (Throwing)AsyncStream
421+
Added: _$sScS12ContinuationV7storageScS8_StorageCyx_Gvg
422+
Added: _$sScS12ContinuationV7storageScS8_StorageCyx_GvpMV
423+
Added: _$sScS8_StorageCMa
424+
Added: _$sScS8_StorageCMn
425+
Added: _$sScS8_StorageCMo
426+
Added: _$sScS8_StorageCMu
427+
Added: _$sScS8_StorageCfD
428+
Added: _$sScS8_StorageCfd
429+
Added: _$sScs12ContinuationV7storageScs8_StorageCyxq__Gvg
430+
Added: _$sScs12ContinuationV7storageScs8_StorageCyxq__GvpMV
431+
Added: _$sScs8_StorageCMa
432+
Added: _$sScs8_StorageCMn
433+
Added: _$sScs8_StorageCMo
434+
Added: _$sScs8_StorageCMu
435+
Added: _$sScs8_StorageCfD
436+
Added: _$sScs8_StorageCfd

test/abi/macOS/x86_64/concurrency.swift

+18
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,21 @@ Added: _swift_task_dealloc_through
416416

417417
// SwiftSettings
418418
Added: _$ss12SwiftSettingVsE16defaultIsolationyABScA_pXpSgFZ
419+
420+
// Hashable for (Throwing)AsyncStream
421+
Added: _$sScS12ContinuationV7storageScS8_StorageCyx_Gvg
422+
Added: _$sScS12ContinuationV7storageScS8_StorageCyx_GvpMV
423+
Added: _$sScS8_StorageCMa
424+
Added: _$sScS8_StorageCMn
425+
Added: _$sScS8_StorageCMo
426+
Added: _$sScS8_StorageCMu
427+
Added: _$sScS8_StorageCfD
428+
Added: _$sScS8_StorageCfd
429+
Added: _$sScs12ContinuationV7storageScs8_StorageCyxq__Gvg
430+
Added: _$sScs12ContinuationV7storageScs8_StorageCyxq__GvpMV
431+
Added: _$sScs8_StorageCMa
432+
Added: _$sScs8_StorageCMn
433+
Added: _$sScs8_StorageCMo
434+
Added: _$sScs8_StorageCMu
435+
Added: _$sScs8_StorageCfD
436+
Added: _$sScs8_StorageCfd

test/api-digester/stability-concurrency-abi.test

+7
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,13 @@ Func withThrowingTaskGroup(of:returning:body:) has parameter 2 type change from
128128
Func withTaskGroup(of:returning:body:) has been renamed to Func withTaskGroup(of:returning:isolation:body:)
129129
Func withTaskGroup(of:returning:body:) has mangled name changing from '_Concurrency.withTaskGroup<A, B where A: Swift.Sendable>(of: A.Type, returning: B.Type, body: (inout Swift.TaskGroup<A>) async -> B) async -> B' to '_Concurrency.withTaskGroup<A, B where A: Swift.Sendable>(of: A.Type, returning: B.Type, isolation: isolated Swift.Optional<Swift.Actor>, body: (inout Swift.TaskGroup<A>) async -> B) async -> B'
130130

131+
// Hashable for (Throwing)AsyncStream
132+
// These are just @usableFromInline:
133+
Var AsyncStream.Continuation.storage is a new API without '@available'
134+
Var AsyncThrowingStream.Continuation.storage is a new API without '@available'
135+
Class AsyncStream._Storage is a new API without '@available'
136+
Class AsyncThrowingStream._Storage is a new API without '@available'
137+
131138
// *** DO NOT DISABLE OR XFAIL THIS TEST. *** (See comment above.)
132139

133140

0 commit comments

Comments
 (0)