-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
+tck #284 support "demand when all downstreams demand" Processor in TCK #287
+tck #284 support "demand when all downstreams demand" Processor in TCK #287
Conversation
Please review @reactive-streams/contributors @viktorklang :-) |
89a4dc3
to
55b1140
Compare
expectRequest(); | ||
final T x = sendNextTFromUpstream(); | ||
expectNextElement(sub1, x); | ||
sub1.request(1); | ||
|
||
// sub1 has received one element, and has one demand pending | ||
// sub2 has not yet requested anything | ||
// sub2 has received one element, and no more pending demand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change is that:
- we did not request from sub2, which made it impossible for "lazy, wait for both" processors to start requesting from upstream
- now we request at least one element from each downstream, causing one element to be signalled down
- we now check that the error signal overtakes the outstanding elements, which was the goal of the test
very nice! |
|
||
@Override | ||
public void request(final long n) { | ||
new Thread(new Runnable() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe to create a new Thread for each request call? Is this the only solution?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed by using the already present execution service here instead of new Thread
@ktoso I just noticed this one. Is this ready for merge? What do we need to proceed with it? |
Oh, and I seem to have missed your review comments in July hm. |
@ktoso let me know when the ping is coming :) |
Thanks for pinging me back, fell through the cracks due to vacation :) |
No worries, just making sure it wasn't dropped on the floor :) |
bc13273
to
4d09161
Compare
@viktorklang addressed the comments, please have a look :) |
@Override | ||
public void subscribe(final Subscriber<? super Integer> s) { | ||
int subscriberCount = subs.size(); | ||
if (subscriberCount == 0) s.onSubscribe(createSubscription(awaitLatch, s, demand1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stylistic comment but I think I'd prefer a switch
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
much more lines, I can convert if you'd prefer that :)
int subscriberCount = subs.size();
switch (subscriberCount) {
case 0:
s.onSubscribe(createSubscription(awaitLatch, s, demand1));
break;
case 1:
s.onSubscribe(createSubscription(awaitLatch, s, demand2));
break;
default:
throw new RuntimeException(String.format("This for-test-purposes-processor supports only 2 subscribers, yet got %s!", subscriberCount));
}
…" Processor in TCK
4d09161
to
7fbd565
Compare
Thanks for the last round of comments @viktorklang, addressed all of them (comments in line explain how) |
Now it's my turn to ping 😉 @viktorklang |
Thanks @ktoso I'll have a look ASAP :) |
ping @viktorklang ;) merge here as well to celebrate the merge day? ;) |
@ktoso Sorry, I've been swamped. I'll have a look now. |
I know, no worries :) |
@Override | ||
public void run() { | ||
if (demand.get() >= 0) { | ||
demand.addAndGet(n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a race-condition here between addAndGet and cancel
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may work but can overflow demand into a negative value.
@ktoso Reviewed. There's a (to me) scary-looking custom Processor implementation. |
Thanks a lot for reviewing – Ouch, so got more work to do here it seems - perfect for the flight tomorrow though :) |
@ktoso No worries. Processor is the trickiest thing to implement. |
|
||
@Override | ||
public void subscribe(final Subscriber<? super Integer> s) { | ||
int subscriberCount = subs.size(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This won't work if subscribe
is called from different threads concurrently.
@ktoso What's the plan here? |
Need to get back to it finally (adding to todolist), day job consuming entire awake-time recently. |
This is a pretty ancient PR - is there enough interest such that I should attempt reviving it? |
@ktoso Well, it's 2 years old so no hurry, for sure. Since we have no idea if/when there'll be a 1.0.2 depending on how much work it is to fix it, it might be better to do it now. |
@ktoso Did we want to make this into 1.0.1? |
I don't think it's critical to include this. |
@ktoso Perhaps we can work on this together? I'd love to be able to either merge or close this issue, so it doesn't linger on. Let me know what you need from me. |
I completely don't remember what this was about right now hm... If you'd be able to check was was missing here please do, currently in a time critical work thing sadly and can't look into this PR. |
I don't know what is missing, I'm. afraid, otherwise I'd take a look at it
:/
On Fri, 10 Nov 2017 at 03:42, ktoso ***@***.***> wrote:
I completely don't remember what this was about right now hm... If you'd
be able to check was was missing here please do, currently in a time
critical work thing sadly and can't look into this PR.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#287 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAqd92R1v7fWPm3BLMVoFa4kheN9EuYks5s07grgaJpZM4FXDWt>
.
--
Cheers,
√
|
Yeah I honestly also don't remember... would need some detective work ~: |
One can implement a The TCK, however, expects that requesting from a |
@akarnokd Hmmm, I see… Do you have any proposal for how we could fix this limitation in the TCK? |
I see two options:
|
@akarnokd It would seem as the first option would be the least involved/error-prone one. Would you like to take a stab at that? |
Sure. |
@akarnokd Awesome |
Close this via #414? |
@akarnokd Yes, thanks! :) |
Resolves #284 not being able to handle "processor that awaits both downstreams before pulling from upstream" in test case
required_spec104_mustCallOnErrorOnAllItsSubscribersIfItEncountersANonRecoverableError
as reported by @RuedigerMoeller.The test-case
required_mustRequestFromUpstreamForElementsThatHaveBeenRequestedLongAgo
pointed out in that ticket will be addressed in a separate PR.