From f59b3f13a90c27cd7beb85d326d63b7b57245859 Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Fri, 29 May 2026 00:44:11 -0700 Subject: [PATCH] Make MultiProducerSingleConsumerAsyncChannel internals compatible with library evolution --- Sources/AsyncAlgorithms/Internal/_TinyArray.swift | 2 ++ ...roducerSingleConsumerAsyncChannel+Internal.swift | 13 ++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Sources/AsyncAlgorithms/Internal/_TinyArray.swift b/Sources/AsyncAlgorithms/Internal/_TinyArray.swift index 4d3e64a2..73572a68 100644 --- a/Sources/AsyncAlgorithms/Internal/_TinyArray.swift +++ b/Sources/AsyncAlgorithms/Internal/_TinyArray.swift @@ -26,8 +26,10 @@ /// It supports arbitrary many elements but if only up to one ``Element`` is stored it does **not** allocate separate storage on the heap /// and instead stores the ``Element`` inline. @usableFromInline +@frozen struct _TinyArray { @usableFromInline + @frozen enum Storage { case one(Element) case arbitrary([Element]) diff --git a/Sources/AsyncAlgorithms/MultiProducerSingleConsumerChannel/MultiProducerSingleConsumerAsyncChannel+Internal.swift b/Sources/AsyncAlgorithms/MultiProducerSingleConsumerChannel/MultiProducerSingleConsumerAsyncChannel+Internal.swift index 296149ac..4a8c07e3 100644 --- a/Sources/AsyncAlgorithms/MultiProducerSingleConsumerChannel/MultiProducerSingleConsumerAsyncChannel+Internal.swift +++ b/Sources/AsyncAlgorithms/MultiProducerSingleConsumerChannel/MultiProducerSingleConsumerAsyncChannel+Internal.swift @@ -16,8 +16,10 @@ import Synchronization @available(AsyncAlgorithms 1.1, *) extension MultiProducerSingleConsumerAsyncChannel { @usableFromInline + @frozen enum _InternalBackpressureStrategy: Sendable, CustomStringConvertible { @usableFromInline + @frozen struct _Watermark: Sendable, CustomStringConvertible { /// The low watermark where demand should start. @usableFromInline @@ -118,7 +120,7 @@ extension MultiProducerSingleConsumerAsyncChannel { @usableFromInline let _stateMachine: Mutex<_StateMachine> - @inlinable + @usableFromInline init( backpressureStrategy: _InternalBackpressureStrategy ) { @@ -505,6 +507,7 @@ extension MultiProducerSingleConsumerAsyncChannel { extension MultiProducerSingleConsumerAsyncChannel._Storage { /// The state machine of the channel. @usableFromInline + @frozen struct _StateMachine: ~Copyable { /// The state machine's current state. @usableFromInline @@ -1358,6 +1361,7 @@ extension MultiProducerSingleConsumerAsyncChannel._Storage { /// destructively pattern-matching an enum case with multiple payloads /// that include a `~Copyable` generic wrapper type (`Disconnected`). @usableFromInline + @frozen struct ResumeElement: ~Copyable, Sendable { @usableFromInline let continuation: UnsafeContinuation @usableFromInline var element: Disconnected @@ -1375,6 +1379,7 @@ extension MultiProducerSingleConsumerAsyncChannel._Storage { /// /// - Note: See `ResumeElement` for the reason behind this wrapper. @usableFromInline + @frozen struct ResumeElementAndProducers: ~Copyable, Sendable { @usableFromInline let continuation: UnsafeContinuation @usableFromInline var element: Disconnected @@ -1395,6 +1400,7 @@ extension MultiProducerSingleConsumerAsyncChannel._Storage { /// /// - Note: See `ResumeElement` for the reason behind this wrapper. @usableFromInline + @frozen struct ResumeFailure: ~Copyable, Sendable { @usableFromInline let continuation: UnsafeContinuation @usableFromInline let failure: Failure? @@ -1560,8 +1566,10 @@ extension MultiProducerSingleConsumerAsyncChannel._Storage { @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) extension MultiProducerSingleConsumerAsyncChannel._Storage._StateMachine { @usableFromInline + @frozen enum _State: ~Copyable { @usableFromInline + @frozen struct Channeling: ~Copyable { /// The backpressure strategy. @usableFromInline @@ -1662,6 +1670,7 @@ extension MultiProducerSingleConsumerAsyncChannel._Storage._StateMachine { } @usableFromInline + @frozen struct SourceFinished: ~Copyable { /// Indicates if the iterator was initialized. @usableFromInline @@ -1718,6 +1727,7 @@ extension MultiProducerSingleConsumerAsyncChannel._Storage._StateMachine { } @usableFromInline + @frozen struct Finished: ~Copyable { /// Indicates if the iterator was initialized. @usableFromInline @@ -1783,6 +1793,7 @@ enum _MultiProducerSingleConsumerSuspendedProducer: @unchecked Sendable { // TODO: This should be replaced with Disconnected once we have a UniqueDeque @usableFromInline +@frozen struct SendableConsumeOnceBox { @usableFromInline var wrapped: Optional