Commit Graph

7 Commits

Author SHA1 Message Date
David Nadoba 75cea45e61
Throw `CancellationError` if `NIOThrowingAsyncSequenceProducer.AsyncIterator.next()` is cancelled instead of returning `nil` (#2399)
* Throw `CancellationError` if `NIOThrowingAsyncSequenceProducer.AsyncIterator.next()` is cancelled instead of returning `nil`

* Update doc comment

* Fix typo
2023-04-05 17:37:43 +01:00
Franz Busch ef7dc666e8
Rework the `NIOAsyncSequenceProducer` tests to rely less on timings (#2386) 2023-03-07 17:28:34 +00:00
carolinacass 5db1dfabb0
Building swift-nio with Swift 5.7 for iOS using Xcode 14.0 at 2.48.0. (#2369)
Motivation:
swift- nio was failing builds that should pass

Modifications:
Adding available to the necessary sections
2023-02-17 10:05:43 -08:00
Franz Busch 0243bb4c8e
Fix `testTaskCancel_whenStreaming_andNotSuspended` flakiness (#2314)
# Motivation
This test has been flaky for some time. This was due to the fact that the consuming Task could have deinited the iterator which has resulted in a call to `didTerminate`.

# Modification
This PR, adds a small sleep in the consuming task to avoid this race.

# Result
No more flakiness in this test.

Co-authored-by: David Nadoba <d_nadoba@apple.com>
2022-11-14 03:20:09 -08:00
David Nadoba c7b4989b02
Remove `#if compiler(>=5.5)` (#2292)
### Motivation
We only support Swift 5.5.2+.

### Modification
Remove all `#if swift(>=5.5)` conditional compilation blocks.

### Result
less branching
2022-10-13 07:17:46 -07:00
Franz Busch 6431296d6b
Call finish once the Source is deinited (#2258)
* Call finish once the Source is deinited

# Motivation
We **MUST** call `finish()` when the `Source` deinits otherwise we can have a suspended continuation that never gets resumed.

# Modification
Introduce an internal class to both `Source`s and call `finish()` in their `deinit`s.

# Result
We are now resuming all continuations.

* Remove @unchecked
2022-09-02 10:01:11 +01:00
Franz Busch ff19f496bd
Add throwing version of `NIOAsyncSequenceProducer` (#2237)
* Add throwing version of `NIOAsyncSequenceProducer`

# Motivation
We recently introduced a `NIOAsyncSequenceProducer` to bridge a stream of elements from the NIO world into the async world. The introduced type was a non-throwing `AsyncSequence`. To support all use-cases we also need to offer a throwing variant of the type.

# Modification
- Introduce a new `NIOThrowingAsyncSequenceProducer` that is identical to the `NIOAsyncSequenceProducer` except that it has a `Failure` generic parameter and that the `next()` method is throwing.
- Extract the `StateMachine` from both `AsyncSequenceProducer`s and unify them.
- There is one modification in behaviour: `didTerminate` is now only called after `nil` or the error has been consumed from the sequence.

# Result
We now have a throwing variant of the `NIOAsyncSequenceProducer`.

* Code review and fix CI

* Remove duplicated code

Co-authored-by: Cory Benfield <lukasa@apple.com>
2022-08-09 23:34:17 -07:00