Skip to content

Commit

Permalink
Consider isRejecting() hints with MoreGatherers.last() (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit authored Oct 18, 2024
1 parent 2cdb067 commit 6e18a8b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/java/com/pivovarit/gatherers/LastGatherer.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public Integrator<AppendOnlyCircularBuffer<T>, T, T> integrator() {

@Override
public BiConsumer<AppendOnlyCircularBuffer<T>, Downstream<? super T>> finisher() {
return (state, downstream) -> state.forEach(downstream::push);
return (state, downstream) -> {
if (!downstream.isRejecting()) {
state.forEach(downstream::push);
}
};
}

static class AppendOnlyCircularBuffer<T> {
Expand Down Expand Up @@ -90,7 +94,7 @@ public Integrator<ValueHolder<T>, T, T> integrator() {
@Override
public BiConsumer<ValueHolder<T>, Downstream<? super T>> finisher() {
return (state, downstream) -> {
if (state.isSet) {
if (state.isSet && !downstream.isRejecting()) {
downstream.push(state.value);
}
};
Expand Down

0 comments on commit 6e18a8b

Please sign in to comment.