Skip to content

Commit 658c95e

Browse files
committed
Addresses PR review comments for #233
1 parent 15f1ca1 commit 658c95e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

tck/src/test/java/org/reactivestreams/tck/SyncTriggeredDemandSubscriberTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public SyncTriggeredDemandSubscriberTest() {
3737
}
3838

3939
@Override public void onComplete() {
40-
System.out.println("Accumulated: " + acc);
4140
}
4241
};
4342
}

tck/src/test/java/org/reactivestreams/tck/support/SyncTriggeredDemandSubscriber.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
import org.reactivestreams.Subscription;
55

66
/**
7-
* SyncSubscriber is an implementation of Reactive Streams `Subscriber`,
8-
* it runs synchronously (on the Publisher's thread) and requests one element
9-
* at a time and invokes a user-defined method to process each element.
7+
* SyncTriggeredDemandSubscriber is an implementation of Reactive Streams `Subscriber`,
8+
* it runs synchronously (on the Publisher's thread) and requests demand triggered from
9+
* "the outside" using its `triggerDemand` method and from "the inside" using the return
10+
* value of its user-defined `foreach` method which is invoked to process each element.
1011
*
1112
* NOTE: The code below uses a lot of try-catches to show the reader where exceptions can be expected, and where they are forbidden.
1213
*/
@@ -32,6 +33,11 @@ public abstract class SyncTriggeredDemandSubscriber<T> implements Subscriber<T>
3233
}
3334
}
3435

36+
/**
37+
* Requests the provided number of elements from the `Subscription` of this `Subscriber`.
38+
* NOTE: This makes no attempt at thread safety so only invoke it once from the outside to initiate the demand.
39+
* @return `true` if successful and `false` if not (either due to no `Subscription` or due to exceptions thrown)
40+
*/
3541
public boolean triggerDemand(final long n) {
3642
final Subscription s = subscription;
3743
if (s == null) return false;

0 commit comments

Comments
 (0)