-
Notifications
You must be signed in to change notification settings - Fork 534
=tck #362 signal onComplete in 201 blackbox verification #372
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,11 +96,25 @@ public void required_spec201_blackbox_mustSignalDemandViaSubscriptionRequest() t | |
@Override | ||
public void run(BlackboxTestStage stage) throws InterruptedException { | ||
triggerRequest(stage.subProxy().sub()); | ||
final long n = stage.expectRequest();// assuming subscriber wants to consume elements... | ||
final long requested = stage.expectRequest();// assuming subscriber wants to consume elements... | ||
final long signalsToEmit = Math.min(requested, 512); // protecting against Subscriber which sends ridiculous large demand | ||
|
||
// should cope with up to requested number of elements | ||
for (int i = 0; i < n; i++) | ||
for (int i = 0; i < signalsToEmit && sampleIsCancelled(stage, i, 10); i++) | ||
stage.signalNext(); | ||
|
||
// we complete after `signalsToEmit` (which can be less than `requested`), | ||
// which is legal under https://github.com/reactive-streams/reactive-streams-jvm#1.2 | ||
stage.sendCompletion(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we sendCompletion() even if cancelled? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not? Cancellation is allowed to be "racy" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the "polite" implementation would check if it is not cancelled before issuing the completion. (so that the implementation does not rely on onComplete if cancelled) |
||
} | ||
|
||
/** | ||
* In order to allow some "skid" and not check state on each iteration, | ||
* only check {@code stage.isCancelled} every {@code checkInterval}'th iteration. | ||
*/ | ||
private boolean sampleIsCancelled(BlackboxTestStage stage, int i, int checkInterval) throws InterruptedException { | ||
if (i % checkInterval == 0) return stage.isCancelled(); | ||
else return false; | ||
} | ||
}); | ||
} | ||
|
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.
Or could be
TestEnvironment.TEST_BUFFER_SIZE
, anything less than huge numbers is fine here though IMO