GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — 2.x: Add MulticastProcessor by akarnokd · Pull Request #6002 · ReactiveX/RxJava Conversation
Member
This PR adds the This type of processor fills the gap of having a backpressure-coordinating processor type as Example: MulticastProcessor<Integer> mp = Flowable.range(1, 10) .subscribeWith(MulticastProcessor.create()); mp.test().assertResult(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // -------------------- MulticastProcessor<Integer> mp2 = MulticastProcessor.create(4); mp2.start(); assertTrue(mp2.offer(1)); assertTrue(mp2.offer(2)); assertTrue(mp2.offer(3)); assertTrue(mp2.offer(4)); assertFalse(mp2.offer(5)); mp2.onComplete(); mp2.test().assertResult(1, 2, 3, 4); Resolves: #5999
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
Codecov Report
@@ Coverage Diff @@ ## 2.x #6002 +/- ## ============================================ + Coverage 98.25% 98.27% +0.01% - Complexity 6062 6158 +96 ============================================ Files 656 659 +3 Lines 44101 44514 +413 Branches 6118 6201 +83 ============================================ + Hits 43333 43745 +412 - Misses 230 231 +1 Partials 538 538
Continue to review full report at Codecov.
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Somehow I missed this PR
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * upstream when all {@link Subscriber}s have cancelled. Late {@code Subscriber}s will then be | ||
| * immediately completed. | ||
| * <p> | ||
| * Because of {@code MulticastProcessor} implements the {@link Subscriber} interface, calling |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I'd nuke the of here
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * {@code onSubscribe} is mandatory (<a href="https://github.com/reactive-streams/reactive-streams-jvm#2.12">Rule 2.12</a>). | ||
| * If {@code MulticastProcessor} shoud run standalone, i.e., without subscribing the {@code MulticastProcessor} to another {@link Publisher}, | ||
| * use {@link #start()} or {@link #startUnbounded()} methods to initialize the internal buffer. | ||
| * Failing to do so will lead to {@link NullPointerException} at runtime. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
lead to a
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| public static <T> MulticastProcessor<T> create() { | ||
| return new MulticastProcessor<T>(bufferSize(), false); | ||
| } | ||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit: double new line
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * @param <T> the input and output value type | ||
| * @return the new MulticastProcessor instance | ||
| */ | ||
| public static <T> MulticastProcessor<T> create(int bufferSize) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
let's add the @CheckReturnValue annotation here
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * is cancelled | ||
| * @return the new MulticastProcessor instance | ||
| */ | ||
| public static <T> MulticastProcessor<T> create(boolean refCount) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
let's add the @CheckReturnValue annotation here
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| * @param <T> the input and output value type | ||
| * @return the new MulticastProcessor instance | ||
| */ | ||
| public static <T> MulticastProcessor<T> create(int bufferSize, boolean refCount) { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
let's add the @CheckReturnValue annotation here
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| } | ||
|
|
||
| /** | ||
| * Constructs a fresh instance with the given prefetch amount and the optional |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
There's no real need of having the documentation here, is there? It's not a public method and the create method already cover everything
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
It may help those who dig into the source code for some reason (learning, debugging, etc.). I'll leave it there.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @Override | ||
| public void onError(Throwable t) { | ||
| if (t == null) { | ||
| throw new NullPointerException("t is null"); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Didn't we also have another second sentence that was stating that nulls are not allowed per definition?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| mp.test().assertResult(); | ||
| } | ||
|
|
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
nit: double new line
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Yep, removed.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| .assertEmpty() | ||
| .requestMore(1) | ||
| .assertValues(0) | ||
| .assertNotComplete() |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Could you just use assertValuesOnly and then save the assertNotComplete call?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.