Skip to content

Allow triggerRequest and signalCancel to be coalesced #462

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,9 @@ public void required_spec208_mustBePreparedToReceiveOnNextSignalsAfterHavingCall
@Override
public void run(WhiteboxTestStage stage) throws InterruptedException {
stage.puppet().triggerRequest(1);
stage.puppet().signalCancel();
stage.expectRequest();
stage.puppet().signalCancel();
stage.expectCancelling();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now we expect the request before signalling cancel, preventing the coalescing of the request and cancel, and by expecting cancelling before signalling next, we ensure that signalling next does test what this test says it tests.

Copy link

Choose a reason for hiding this comment

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

Sounds reasonable and less prone to race conditions.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1. the behavior you described sounds like an improvement.

stage.signalNext();

stage.puppet().triggerRequest(1);
Expand Down Expand Up @@ -812,11 +813,17 @@ public interface SubscriberPuppet {
* Before sending any element to the subscriber, the TCK must wait for the subscriber to request that element, and
* must be prepared for the subscriber to only request one element at a time, it is not enough for the TCK to
* simply invoke this method before sending elements.
* <p>
* An invocation of {@link #signalCancel()} may be coalesced into any elements that have not yet been requested,
* such that only a cancel signal is emitted.
*/
void triggerRequest(long elements);

/**
* Trigger {@code cancel()} on your {@link Subscriber}
* Trigger {@code cancel()} on your {@link Subscriber}.
* <p/>
* An invocation of this method may be coalesced into any outstanding requests, as requested by
* {@link #triggerRequest(long)}, such that only a cancel signal is emitted.
*/
void signalCancel();
}
Expand Down