Skip to content

Commit 3a1a255

Browse files
committed
Add more tests and fix upstream throw behaviour
1 parent 340277c commit 3a1a255

File tree

5 files changed

+348
-188
lines changed

5 files changed

+348
-188
lines changed

Sources/AsyncAlgorithms/Merge/AsyncMerge2Sequence.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ extension AsyncMerge2Sequence: AsyncSequence {
7979
}
8080
}
8181

82-
public extension AsyncMerge2Sequence {
83-
struct AsyncIterator: AsyncIteratorProtocol {
82+
extension AsyncMerge2Sequence {
83+
public struct AsyncIterator: AsyncIteratorProtocol {
8484
/// This class is needed to hook the deinit to observe once all references to the ``AsyncIterator`` are dropped.
8585
///
8686
/// If we get move-only types we should be able to drop this class and use the `deinit` of the ``AsyncIterator`` struct itself.

Sources/AsyncAlgorithms/Merge/MergeStateMachine.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,12 @@ struct MergeStateMachine<
9292
// An iterator was created and we deinited the sequence.
9393
// This is an expected pattern and we just continue on normal.
9494
// Importantly since we are a unicast sequence no more iterators can be created
95-
break
95+
return
9696

9797
case .finished:
9898
// We are already finished so there is nothing left to clean up.
9999
// This is just the references dropping afterwards.
100-
break
100+
return
101101

102102
case .modifying:
103103
preconditionFailure("Invalid state")
@@ -160,7 +160,7 @@ struct MergeStateMachine<
160160
case .upstreamFailure:
161161
// The iterator was dropped which signals that the consumer is finished.
162162
// We can transition to finished now. The cleanup already happened when we
163-
// transitioned to `upstreamThrew`.
163+
// transitioned to `upstreamFailure`.
164164
state = .finished
165165

166166
return .none

0 commit comments

Comments
 (0)