Skip to content

Commit

Permalink
Add more tests and fix upstream throw behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
FranzBusch committed Sep 9, 2022
1 parent 340277c commit 3a1a255
Show file tree
Hide file tree
Showing 5 changed files with 348 additions and 188 deletions.
4 changes: 2 additions & 2 deletions Sources/AsyncAlgorithms/Merge/AsyncMerge2Sequence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ extension AsyncMerge2Sequence: AsyncSequence {
}
}

public extension AsyncMerge2Sequence {
struct AsyncIterator: AsyncIteratorProtocol {
extension AsyncMerge2Sequence {
public struct AsyncIterator: AsyncIteratorProtocol {
/// This class is needed to hook the deinit to observe once all references to the ``AsyncIterator`` are dropped.
///
/// If we get move-only types we should be able to drop this class and use the `deinit` of the ``AsyncIterator`` struct itself.
Expand Down
6 changes: 3 additions & 3 deletions Sources/AsyncAlgorithms/Merge/MergeStateMachine.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ struct MergeStateMachine<
// An iterator was created and we deinited the sequence.
// This is an expected pattern and we just continue on normal.
// Importantly since we are a unicast sequence no more iterators can be created
break
return

case .finished:
// We are already finished so there is nothing left to clean up.
// This is just the references dropping afterwards.
break
return

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

return .none
Expand Down
Loading

0 comments on commit 3a1a255

Please sign in to comment.