Skip to content

Commit

Permalink
fix: don't use list but concurrent linked queue (#514)
Browse files Browse the repository at this point in the history
see: #500
  • Loading branch information
sdelamo authored Dec 22, 2020
1 parent c05dc37 commit 35451ee
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;

import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand All @@ -50,7 +50,7 @@ class CacheableProcessor<T> implements Processor<T, T> {
private Subscription subscription;

@NonNull
private List<ElementSubscription<T>> subscriptions = new ArrayList<>();
private Queue<ElementSubscription<T>> subscriptions = new ConcurrentLinkedQueue<>();

@Nullable
private final Function<T, T> transformer;
Expand Down Expand Up @@ -83,7 +83,7 @@ public void clear() {
}
subscriptions = subscriptions.stream()
.filter(elementSubscription -> !elementSubscription.isCanceled() && !elementSubscription.isComplete())
.collect(Collectors.toList());
.collect(Collectors.toCollection(ConcurrentLinkedQueue::new));
}

// Subscriber
Expand Down

0 comments on commit 35451ee

Please sign in to comment.