From 6c6ed33514ace1b569ff122c4506a917f4aec894 Mon Sep 17 00:00:00 2001 From: Franz Busch Date: Thu, 20 Oct 2022 17:34:24 +0100 Subject: [PATCH] Remove Sendability from all Iterators (#219) # Motivation We have been discussing this a lot in the other PRs, but in general said that an `AsyncIterator` is the connection between the consuming task and the `AsyncSequence`. If an `AsyncIterator` would be `Sendable` then we don't have that relationship anymore. Therefore, no iterator of an `AsyncIterator` should be `Sendable`. # Modification Remove all `Sendable` conformances of the iterators even the conditional ones. We can always add them back later. --- .../AsyncAlgorithms.docc/Guides/Effects.md | 56 +++++++++---------- .../AsyncAlgorithms/AsyncBufferSequence.swift | 1 - .../AsyncAlgorithms/AsyncChain3Sequence.swift | 1 - .../AsyncCompactedSequence.swift | 1 - .../AsyncExclusiveReductionsSequence.swift | 1 - .../AsyncInclusiveReductionsSequence.swift | 1 - .../AsyncInterspersedSequence.swift | 2 - .../AsyncJoinedBySeparatorSequence.swift | 6 -- .../AsyncAlgorithms/AsyncJoinedSequence.swift | 4 -- .../AsyncAlgorithms/AsyncLazySequence.swift | 1 - .../AsyncRemoveDuplicatesSequence.swift | 2 - .../AsyncThrottleSequence.swift | 3 - ...cThrowingExclusiveReductionsSequence.swift | 1 - ...cThrowingInclusiveReductionsSequence.swift | 1 - .../AsyncAlgorithms/AsyncTimerSequence.swift | 3 - .../Support/GatedSequence.swift | 1 - 16 files changed, 28 insertions(+), 57 deletions(-) diff --git a/Sources/AsyncAlgorithms/AsyncAlgorithms.docc/Guides/Effects.md b/Sources/AsyncAlgorithms/AsyncAlgorithms.docc/Guides/Effects.md index 766d54d..5d7a596 100644 --- a/Sources/AsyncAlgorithms/AsyncAlgorithms.docc/Guides/Effects.md +++ b/Sources/AsyncAlgorithms/AsyncAlgorithms.docc/Guides/Effects.md @@ -1,59 +1,59 @@ | Type | Throws | Sendability | |-----------------------------------------------------|--------------|-------------| | `AsyncAdjacentPairsSequence` | rethrows | Conditional | -| `AsyncBufferedByteIterator` | throws | Sendable | +| `AsyncBufferedByteIterator` | throws | Not Sendable| | `AsyncBufferSequence` | rethrows | Conditional | -| `AsyncBufferSequence.Iterator` | rethrows | Conditional | +| `AsyncBufferSequence.Iterator` | rethrows | Not Sendable| | `AsyncChain2Sequence` | rethrows | Conditional | -| `AsyncChain2Sequence.Iterator` | rethrows | Conditional | +| `AsyncChain2Sequence.Iterator` | rethrows | Not Sendable| | `AsyncChain3Sequence` | rethrows | Conditional | -| `AsyncChain3Sequence.Iterator` | rethrows | Conditional | +| `AsyncChain3Sequence.Iterator` | rethrows | Not Sendable| | `AsyncChannel` | non-throwing | Sendable | -| `AsyncChannel.Iterator` | non-throwing | Sendable | +| `AsyncChannel.Iterator` | non-throwing | Not Sendable| | `AsyncChunkedByGroupSequence` | rethrows | Conditional | -| `AsyncChunkedByGroupSequence.Iterator` | rethrows | Conditional | +| `AsyncChunkedByGroupSequence.Iterator` | rethrows | Not Sendable| | `AsyncChunkedOnProjectionSequence` | rethrows | Conditional | -| `AsyncChunkedOnProjectionSequence.Iterator` | rethrows | Conditional | +| `AsyncChunkedOnProjectionSequence.Iterator` | rethrows | Not Sendable| | `AsyncChunksOfCountOrSignalSequence` | rethrows | Sendable | -| `AsyncChunksOfCountOrSignalSequence.Iterator` | rethrows | Sendable | +| `AsyncChunksOfCountOrSignalSequence.Iterator` | rethrows | Not Sendable| | `AsyncChunksOfCountSequence` | rethrows | Conditional | -| `AsyncChunksOfCountSequence.Iterator` | rethrows | Conditional | +| `AsyncChunksOfCountSequence.Iterator` | rethrows | Not Sendable| | `AsyncCombineLatest2Sequence` | rethrows | Sendable | -| `AsyncCombineLatest2Sequence.Iterator` | rethrows | Sendable | +| `AsyncCombineLatest2Sequence.Iterator` | rethrows | Not Sendable| | `AsyncCombineLatest3Sequence` | rethrows | Sendable | -| `AsyncCombineLatest3Sequence.Iterator` | rethrows | Sendable | +| `AsyncCombineLatest3Sequence.Iterator` | rethrows | Not Sendable| | `AsyncCompactedSequence` | rethrows | Conditional | -| `AsyncCompactedSequence.Iterator` | rethrows | Conditional | +| `AsyncCompactedSequence.Iterator` | rethrows | Not Sendable| | `AsyncDebounceSequence` | rethrows | Sendable | -| `AsyncDebounceSequence.Iterator` | rethrows | Sendable | +| `AsyncDebounceSequence.Iterator` | rethrows | Not Sendable| | `AsyncExclusiveReductionsSequence` | rethrows | Conditional | -| `AsyncExclusiveReductionsSequence.Iterator` | rethrows | Conditional | +| `AsyncExclusiveReductionsSequence.Iterator` | rethrows | Not Sendable| | `AsyncInclusiveReductionsSequence` | rethrows | Conditional | -| `AsyncInclusiveReductionsSequence.Iterator` | rethrows | Conditional | +| `AsyncInclusiveReductionsSequence.Iterator` | rethrows | Not Sendable| | `AsyncInterspersedSequence` | rethrows | Conditional | -| `AsyncInterspersedSequence.Iterator` | rethrows | Conditional | +| `AsyncInterspersedSequence.Iterator` | rethrows | Not Sendable| | `AsyncJoinedSequence` | rethrows | Conditional | -| `AsyncJoinedSequence.Iterator` | rethrows | Conditional | +| `AsyncJoinedSequence.Iterator` | rethrows | Not Sendable| | `AsyncLazySequence` | non-throwing | Conditional | -| `AsyncLazySequence.Iterator` | non-throwing | Conditional | +| `AsyncLazySequence.Iterator` | non-throwing | Not Sendable| | `AsyncLimitBuffer` | non-throwing | Sendable | | `AsyncMerge2Sequence` | rethrows | Sendable | -| `AsyncMerge2Sequence.Iterator` | rethrows | Sendable | +| `AsyncMerge2Sequence.Iterator` | rethrows | Not Sendable| | `AsyncMerge3Sequence` | rethrows | Sendable | -| `AsyncMerge3Sequence.Iterator` | rethrows | Sendable | +| `AsyncMerge3Sequence.Iterator` | rethrows | Not Sendable| | `AsyncRemoveDuplicatesSequence` | rethrows | Conditional | -| `AsyncRemoveDuplicatesSequence.Iterator` | rethrows | Conditional | +| `AsyncRemoveDuplicatesSequence.Iterator` | rethrows | Not Sendable| | `AsyncThrottleSequence` | rethrows | Conditional | -| `AsyncThrottleSequence.Iterator` | rethrows | Conditional | +| `AsyncThrottleSequence.Iterator` | rethrows | Not Sendable| | `AsyncThrowingChannel` | throws | Sendable | -| `AsyncThrowingChannel.Iterator` | throws | Sendable | +| `AsyncThrowingChannel.Iterator` | throws | Not Sendable| | `AsyncThrowingExclusiveReductionsSequence` | throws | Conditional | -| `AsyncThrowingExclusiveReductionsSequence.Iterator` | throws | Conditional | +| `AsyncThrowingExclusiveReductionsSequence.Iterator` | throws | Not Sendable| | `AsyncThrowingInclusiveReductionsSequence` | throws | Conditional | -| `AsyncThrowingInclusiveReductionsSequence.Iterator` | throws | Conditional | +| `AsyncThrowingInclusiveReductionsSequence.Iterator` | throws | Not Sendable| | `AsyncTimerSequence` | non-throwing | Sendable | -| `AsyncTimerSequence.Iterator` | non-throwing | Sendable | +| `AsyncTimerSequence.Iterator` | non-throwing | Not Sendable| | `AsyncZip2Sequence` | rethrows | Sendable | -| `AsyncZip2Sequence.Iterator` | rethrows | Sendable | +| `AsyncZip2Sequence.Iterator` | rethrows | Not Sendable| | `AsyncZip3Sequence` | rethrows | Sendable | -| `AsyncZip3Sequence.Iterator` | rethrows | Sendable | +| `AsyncZip3Sequence.Iterator` | rethrows | Not Sendable| diff --git a/Sources/AsyncAlgorithms/AsyncBufferSequence.swift b/Sources/AsyncAlgorithms/AsyncBufferSequence.swift index 2b43fae..96fad74 100644 --- a/Sources/AsyncAlgorithms/AsyncBufferSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncBufferSequence.swift @@ -235,7 +235,6 @@ public struct AsyncBufferSequence wher } extension AsyncBufferSequence: Sendable where Base: Sendable { } -extension AsyncBufferSequence.Iterator: Sendable where Base: Sendable { } extension AsyncBufferSequence: AsyncSequence { public typealias Element = Buffer.Output diff --git a/Sources/AsyncAlgorithms/AsyncChain3Sequence.swift b/Sources/AsyncAlgorithms/AsyncChain3Sequence.swift index 8185a22..1c275a2 100644 --- a/Sources/AsyncAlgorithms/AsyncChain3Sequence.swift +++ b/Sources/AsyncAlgorithms/AsyncChain3Sequence.swift @@ -95,4 +95,3 @@ extension AsyncChain3Sequence: AsyncSequence { } extension AsyncChain3Sequence: Sendable where Base1: Sendable, Base2: Sendable, Base3: Sendable { } -extension AsyncChain3Sequence.Iterator: Sendable where Base1.AsyncIterator: Sendable, Base2.AsyncIterator: Sendable, Base3.AsyncIterator: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncCompactedSequence.swift b/Sources/AsyncAlgorithms/AsyncCompactedSequence.swift index 0cfacec..5b96bc9 100644 --- a/Sources/AsyncAlgorithms/AsyncCompactedSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncCompactedSequence.swift @@ -69,4 +69,3 @@ extension AsyncSequence { } extension AsyncCompactedSequence: Sendable where Base: Sendable, Base.Element: Sendable, Base.AsyncIterator: Sendable { } -extension AsyncCompactedSequence.Iterator: Sendable where Base: Sendable, Base.Element: Sendable, Base.AsyncIterator: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncExclusiveReductionsSequence.swift b/Sources/AsyncAlgorithms/AsyncExclusiveReductionsSequence.swift index a0998ef..0d56c59 100644 --- a/Sources/AsyncAlgorithms/AsyncExclusiveReductionsSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncExclusiveReductionsSequence.swift @@ -112,4 +112,3 @@ extension AsyncExclusiveReductionsSequence: AsyncSequence { } extension AsyncExclusiveReductionsSequence: Sendable where Base: Sendable, Element: Sendable { } -extension AsyncExclusiveReductionsSequence.Iterator: Sendable where Base.AsyncIterator: Sendable, Element: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncInclusiveReductionsSequence.swift b/Sources/AsyncAlgorithms/AsyncInclusiveReductionsSequence.swift index cf52cb8..12611c1 100644 --- a/Sources/AsyncAlgorithms/AsyncInclusiveReductionsSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncInclusiveReductionsSequence.swift @@ -85,4 +85,3 @@ extension AsyncInclusiveReductionsSequence: AsyncSequence { } extension AsyncInclusiveReductionsSequence: Sendable where Base: Sendable { } -extension AsyncInclusiveReductionsSequence.Iterator: Sendable where Base.AsyncIterator: Sendable, Base.Element: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncInterspersedSequence.swift b/Sources/AsyncAlgorithms/AsyncInterspersedSequence.swift index d50d721..8d8e1b5 100644 --- a/Sources/AsyncAlgorithms/AsyncInterspersedSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncInterspersedSequence.swift @@ -100,5 +100,3 @@ extension AsyncInterspersedSequence: AsyncSequence { } extension AsyncInterspersedSequence: Sendable where Base: Sendable, Base.Element: Sendable, Base.AsyncIterator: Sendable { } -extension AsyncInterspersedSequence.Iterator: Sendable where Base: Sendable, Base.Element: Sendable, Base.AsyncIterator: Sendable { } -extension AsyncInterspersedSequence.Iterator.State: Sendable where Base: Sendable, Base.Element: Sendable, Base.AsyncIterator: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncJoinedBySeparatorSequence.swift b/Sources/AsyncAlgorithms/AsyncJoinedBySeparatorSequence.swift index 492d703..e401eea 100644 --- a/Sources/AsyncAlgorithms/AsyncJoinedBySeparatorSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncJoinedBySeparatorSequence.swift @@ -142,9 +142,3 @@ public struct AsyncJoinedBySeparatorSequence: AsyncSequence where Base extension AsyncJoinedSequence: Sendable where Base: Sendable, Base.Element: Sendable, Base.Element.Element: Sendable, Base.AsyncIterator: Sendable, Base.Element.AsyncIterator: Sendable { } -extension AsyncJoinedSequence.Iterator: Sendable -where Base: Sendable, Base.Element: Sendable, Base.Element.Element: Sendable, Base.AsyncIterator: Sendable, Base.Element.AsyncIterator: Sendable { } -extension AsyncJoinedSequence.Iterator.State: Sendable -where Base: Sendable, Base.Element: Sendable, Base.Element.Element: Sendable, Base.AsyncIterator: Sendable, Base.Element.AsyncIterator: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncLazySequence.swift b/Sources/AsyncAlgorithms/AsyncLazySequence.swift index 9c2aa1e..9a8abd7 100644 --- a/Sources/AsyncAlgorithms/AsyncLazySequence.swift +++ b/Sources/AsyncAlgorithms/AsyncLazySequence.swift @@ -67,4 +67,3 @@ public struct AsyncLazySequence: AsyncSequence { } extension AsyncLazySequence: Sendable where Base: Sendable { } -extension AsyncLazySequence.Iterator: Sendable where Base.Iterator: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncRemoveDuplicatesSequence.swift b/Sources/AsyncAlgorithms/AsyncRemoveDuplicatesSequence.swift index 60f3aa4..5fcd095 100644 --- a/Sources/AsyncAlgorithms/AsyncRemoveDuplicatesSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncRemoveDuplicatesSequence.swift @@ -86,7 +86,6 @@ public struct AsyncRemoveDuplicatesSequence: AsyncSequence } extension AsyncRemoveDuplicatesSequence: Sendable where Base: Sendable, Base.Element: Sendable, Base.AsyncIterator: Sendable { } -extension AsyncRemoveDuplicatesSequence.Iterator: Sendable where Base: Sendable, Base.Element: Sendable, Base.AsyncIterator: Sendable { } /// An asynchronous sequence that omits repeated elements by testing them with an error-throwing predicate. @@ -145,4 +144,3 @@ public struct AsyncThrowingRemoveDuplicatesSequence: AsyncS } extension AsyncThrowingRemoveDuplicatesSequence: Sendable where Base: Sendable, Base.Element: Sendable, Base.AsyncIterator: Sendable { } -extension AsyncThrowingRemoveDuplicatesSequence.Iterator: Sendable where Base: Sendable, Base.Element: Sendable, Base.AsyncIterator: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncThrottleSequence.swift b/Sources/AsyncAlgorithms/AsyncThrottleSequence.swift index ad590af..4832b9a 100644 --- a/Sources/AsyncAlgorithms/AsyncThrottleSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncThrottleSequence.swift @@ -102,6 +102,3 @@ extension AsyncThrottleSequence: AsyncSequence { @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) extension AsyncThrottleSequence: Sendable where Base: Sendable, Element: Sendable { } - -@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) -extension AsyncThrottleSequence.Iterator: Sendable where Base.AsyncIterator: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncThrowingExclusiveReductionsSequence.swift b/Sources/AsyncAlgorithms/AsyncThrowingExclusiveReductionsSequence.swift index 303c21c..4b12c2c 100644 --- a/Sources/AsyncAlgorithms/AsyncThrowingExclusiveReductionsSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncThrowingExclusiveReductionsSequence.swift @@ -119,4 +119,3 @@ extension AsyncThrowingExclusiveReductionsSequence: AsyncSequence { } extension AsyncThrowingExclusiveReductionsSequence: Sendable where Base: Sendable, Element: Sendable { } -extension AsyncThrowingExclusiveReductionsSequence.Iterator: Sendable where Base.AsyncIterator: Sendable, Element: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncThrowingInclusiveReductionsSequence.swift b/Sources/AsyncAlgorithms/AsyncThrowingInclusiveReductionsSequence.swift index 673d7c5..36e88fb 100644 --- a/Sources/AsyncAlgorithms/AsyncThrowingInclusiveReductionsSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncThrowingInclusiveReductionsSequence.swift @@ -89,4 +89,3 @@ extension AsyncThrowingInclusiveReductionsSequence: AsyncSequence { } extension AsyncThrowingInclusiveReductionsSequence: Sendable where Base: Sendable { } -extension AsyncThrowingInclusiveReductionsSequence.Iterator: Sendable where Base.AsyncIterator: Sendable, Base.Element: Sendable { } diff --git a/Sources/AsyncAlgorithms/AsyncTimerSequence.swift b/Sources/AsyncAlgorithms/AsyncTimerSequence.swift index 795cfa4..fe3b58f 100644 --- a/Sources/AsyncAlgorithms/AsyncTimerSequence.swift +++ b/Sources/AsyncAlgorithms/AsyncTimerSequence.swift @@ -89,6 +89,3 @@ extension AsyncTimerSequence where C == SuspendingClock { @available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) extension AsyncTimerSequence: Sendable { } - -@available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) -extension AsyncTimerSequence.Iterator: Sendable { } diff --git a/Tests/AsyncAlgorithmsTests/Support/GatedSequence.swift b/Tests/AsyncAlgorithmsTests/Support/GatedSequence.swift index 50ede10..71c618b 100644 --- a/Tests/AsyncAlgorithmsTests/Support/GatedSequence.swift +++ b/Tests/AsyncAlgorithmsTests/Support/GatedSequence.swift @@ -52,4 +52,3 @@ extension GatedSequence: AsyncSequence { } extension GatedSequence: Sendable where Element: Sendable { } -extension GatedSequence.Iterator: Sendable where Element: Sendable { }