< prev index next >

jdk/src/java.base/share/classes/java/util/concurrent/Flow.java

Print this page




 144  * }}</pre>
 145  *
 146  * <p>The default value of {@link #defaultBufferSize} may provide a
 147  * useful starting point for choosing request sizes and capacities in
 148  * Flow components based on expected rates, resources, and usages.
 149  * Or, when flow control is never needed, a subscriber may initially
 150  * request an effectively unbounded number of items, as in:
 151  *
 152  * <pre> {@code
 153  * class UnboundedSubscriber<T> implements Subscriber<T> {
 154  *   public void onSubscribe(Subscription subscription) {
 155  *     subscription.request(Long.MAX_VALUE); // effectively unbounded
 156  *   }
 157  *   public void onNext(T item) { use(item); }
 158  *   public void onError(Throwable ex) { ex.printStackTrace(); }
 159  *   public void onComplete() {}
 160  *   void use(T item) { ... }
 161  * }}</pre>
 162  *
 163  * @author Doug Lea
 164  * @since 1.9
 165  */
 166 public final class Flow {
 167 
 168     private Flow() {} // uninstantiable
 169 
 170     /**
 171      * A producer of items (and related control messages) received by
 172      * Subscribers.  Each current {@link Subscriber} receives the same
 173      * items (via method {@code onNext}) in the same order, unless
 174      * drops or errors are encountered. If a Publisher encounters an
 175      * error that does not allow items to be issued to a Subscriber,
 176      * that Subscriber receives {@code onError}, and then receives no
 177      * further messages.  Otherwise, when it is known that no further
 178      * messages will be issued to it, a subscriber receives {@code
 179      * onComplete}.  Publishers ensure that Subscriber method
 180      * invocations for each subscription are strictly ordered in <a
 181      * href="package-summary.html#MemoryVisibility"><i>happens-before</i></a>
 182      * order.
 183      *
 184      * <p>Publishers may vary in policy about whether drops (failures




 144  * }}</pre>
 145  *
 146  * <p>The default value of {@link #defaultBufferSize} may provide a
 147  * useful starting point for choosing request sizes and capacities in
 148  * Flow components based on expected rates, resources, and usages.
 149  * Or, when flow control is never needed, a subscriber may initially
 150  * request an effectively unbounded number of items, as in:
 151  *
 152  * <pre> {@code
 153  * class UnboundedSubscriber<T> implements Subscriber<T> {
 154  *   public void onSubscribe(Subscription subscription) {
 155  *     subscription.request(Long.MAX_VALUE); // effectively unbounded
 156  *   }
 157  *   public void onNext(T item) { use(item); }
 158  *   public void onError(Throwable ex) { ex.printStackTrace(); }
 159  *   public void onComplete() {}
 160  *   void use(T item) { ... }
 161  * }}</pre>
 162  *
 163  * @author Doug Lea
 164  * @since 9
 165  */
 166 public final class Flow {
 167 
 168     private Flow() {} // uninstantiable
 169 
 170     /**
 171      * A producer of items (and related control messages) received by
 172      * Subscribers.  Each current {@link Subscriber} receives the same
 173      * items (via method {@code onNext}) in the same order, unless
 174      * drops or errors are encountered. If a Publisher encounters an
 175      * error that does not allow items to be issued to a Subscriber,
 176      * that Subscriber receives {@code onError}, and then receives no
 177      * further messages.  Otherwise, when it is known that no further
 178      * messages will be issued to it, a subscriber receives {@code
 179      * onComplete}.  Publishers ensure that Subscriber method
 180      * invocations for each subscription are strictly ordered in <a
 181      * href="package-summary.html#MemoryVisibility"><i>happens-before</i></a>
 182      * order.
 183      *
 184      * <p>Publishers may vary in policy about whether drops (failures


< prev index next >