ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/main/java/util/concurrent/Flow.java
(Generate patch)

Comparing jsr166/src/main/java/util/concurrent/Flow.java (file contents):
Revision 1.17 by dl, Mon Jan 19 18:15:09 2015 UTC vs.
Revision 1.18 by dl, Fri Jan 23 13:48:41 2015 UTC

# Line 117 | Line 117 | import java.util.stream.Stream;
117   *   public void onComplete() {}
118   * }}</pre>
119   *
120 < * <p>When flow control is inapplicable, a subscriber may initially
121 < * request an effectively unbounded number of items, as in:
120 > * <p>The default value of {@link #defaultBufferSize} may provide a
121 > * useful starting point for choosing request sizes and capacities in
122 > * Flow components based on expected rates, resources, and usages.
123 > * Or, when flow control is known to be always inapplicable, a
124 > * subscriber may initially request an effectively unbounded number of
125 > * items, as in:
126   *
127   * <pre> {@code
128   * class UnboundedSubscriber<T> implements Subscriber<T> {
# Line 274 | Line 278 | public final class Flow {
278  
279      // Support for static methods
280  
281 <    static final long DEFAULT_BUFFER_SIZE = 64L;
281 >    static final int DEFAULT_BUFFER_SIZE = 256;
282 >
283 >    /**
284 >     * Returns a default value for Publisher or Subscriber buffering,
285 >     * that may be used in the absence of other constraints.
286 >     *
287 >     * @implNote
288 >     * The current value returned is 256.
289 >     *
290 >     * @return the buffer size value
291 >     */
292 >    public static int defaultBufferSize() {
293 >        return DEFAULT_BUFFER_SIZE;
294 >    }
295  
296      abstract static class CompletableSubscriber<T,U> implements Subscriber<T>,
297                                                                  Consumer<T> {
# Line 349 | Line 366 | public final class Flow {
366  
367      /**
368       * Equivalent to {@link #consume(long, Publisher, Consumer)}
369 <     * with a buffer size of 64.
369 >     * with {@link #defaultBufferSize}.
370       *
371       * @param <T> the published item type
372       * @param publisher the publisher
# Line 361 | Line 378 | public final class Flow {
378       */
379      public static <T> CompletableFuture<Void> consume(
380          Publisher<T> publisher, Consumer<? super T> consumer) {
381 <        return consume(DEFAULT_BUFFER_SIZE, publisher, consumer);
381 >        return consume(defaultBufferSize(), publisher, consumer);
382      }
383  
384      /**
# Line 420 | Line 437 | public final class Flow {
437  
438      /**
439       * Equivalent to {@link #stream(long, Publisher, Function)}
440 <     * with a buffer size of 64.
440 >     * with {@link #defaultBufferSize}.
441       *
442       * @param <T> the published item type
443       * @param <R> the result type of the stream function
# Line 434 | Line 451 | public final class Flow {
451      public static <T,R> CompletableFuture<R> stream(
452          Publisher<T> publisher,
453          Function<? super Stream<T>,? extends R> streamFunction) {
454 <        return stream(DEFAULT_BUFFER_SIZE, publisher, streamFunction);
454 >        return stream(defaultBufferSize(), publisher, streamFunction);
455      }
456   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines