Skip to content
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

Multi discrepancies #2413

Merged
merged 3 commits into from Oct 7, 2020
Merged

Conversation

danielkec
Copy link
Contributor

Signed-off-by: Daniel Kec daniel.kec@oracle.com

Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
value = item; // assert: even if the race occurs, we will deliver one of the items with which complete()
// has been invoked - we support only the case with a single invocation of complete()
int state = getAndUpdate(n -> n | VALUE_ARRIVED);
if ((state & REQUEST_ARRIVED) == REQUEST_ARRIVED) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why you added the masking of the value. getAndUpdate returns the value that existed before - so comparing to just REQUEST_ARRIVED in the POC was intentional.

a. in the case that we support masking makes no difference.
b. if the method is abused, and does get called more than once, the POC would still deliver only one value, and masking will deliver more than one value, and break the spec by delivering onNext after onComplete.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that the masking in line 89 is redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aha I see, but it makes sense in the other complete() right?

    public final void complete() {
        int state = get();
        if (((state & VALUE_ARRIVED) != VALUE_ARRIVED) && compareAndSet(state, DONE)){
            downstream.onComplete();
        }
    }

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in the other complete it reflects the logic of the POC correctly: basically, in that complete it is "if value has not arrived yet" (was worded with different conditions with OR).

But in this complete the logic must be "if request has been seen, but the value still not seen" - only in that case we are allowed to deliver the signals to downstream.

@@ -98,6 +98,7 @@ public void nextSource() {
@Override
public void request(long n) {
if (n <= 0) {
cancel();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not sufficient for the problem that has been discovered. We'll have to address it better.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@olotenko To be clear, your point is that the sequence onError onNext is still possible as cancellation is only a best-effort task.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you can view this as the best effort so far. But like I mentioned offline, there is another issue that needs addressing, so we may just as well postpone touching this class.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, sounds like for a future PR.

Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
@danielkec danielkec added the reactive Reactive streams and related components label Oct 6, 2020
@danielkec danielkec self-assigned this Oct 6, 2020
olotenko
olotenko previously approved these changes Oct 6, 2020
Copy link

@olotenko olotenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am indifferent to the change in MultiConcatArray. DeferredScalarSubscription is good.

Signed-off-by: Daniel Kec <daniel.kec@oracle.com>
@danielkec danielkec merged commit 9aa8185 into helidon-io:master Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
reactive Reactive streams and related components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants