Only iterate through subfutures/substreams that have woken #119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is dependent on #118.
This is a large PR, containing the primary change from #115.
Benchmark
after = this PR
before = #118
As shown, the runtime now grows linearly with number of futures.
API changes
Tuples combinator now support more heterogeneous outputs, but in a more restricted way than #115 .
Making the remaining heterogeneous would require the
select_types
enum solution used in Waker optimization + O(woken) polling for every combinator except chain #115. I've been using that myself and find it clumsy- requiring weird enum matches and verbose type annotations.For RaceOk, AggregateError has been unified-
vec
vec::AggregateError<E>
AggregateError<Vec<E>>
array
array::AggregateError<E, N>
AggregateError<[E; N]>
tuple
tuple::AggregateError<E, N>
AggregateError<(E1, E2, ...)>
The new AggregateError is also simpler- instead of implementing Deref and DerefMut it now has public errors field.
Organizational changes
As in #115, the four future combinators are unified into a common module to avoid code duplication. In the
future::common
module, I implemented generic combinators whose behavior can be customized to match Join/Race/RaceOk/TryJoin via a generic type parameter.