You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@Overridepublicvoidrun(BlackboxTestStagestage) throwsInterruptedException {
triggerRequest(stage.subProxy().sub());
finallongrequested = stage.expectRequest();// assuming subscriber wants to consume elements...finallongsignalsToEmit = Math.min(requested, 512); // protecting against Subscriber which sends ridiculously large demand// should cope with up to requested number of elementsfor (inti = 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.2stage.sendCompletion();
}
/** * In order to allow some "skid" and not check state on each iteration, * only check {@code stage.isCancelled} every {@code checkInterval}'th iteration. */privatebooleansampleIsCancelled(BlackboxTestStagestage, inti, intcheckInterval) throwsInterruptedException {
if (i % checkInterval == 0) returnstage.isCancelled();
elsereturnfalse;
}
I have a question about the use of the sampleIsCancelled method in the snippet above. It seems strange that the for loop uses that method's (naked) return value rather than a negation thereof. As far as I can see in the typical scenario it leads to the loop's body being executed at most once. Was it by design?
The text was updated successfully, but these errors were encountered:
I have a question about the use of the
sampleIsCancelled
method in the snippet above. It seems strange that thefor
loop uses that method's (naked) return value rather than a negation thereof. As far as I can see in the typical scenario it leads to the loop's body being executed at most once. Was it by design?The text was updated successfully, but these errors were encountered: