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

Comparing jsr166/src/main/java/util/concurrent/CompletableFuture.java (file contents):
Revision 1.178 by jsr166, Sat Oct 3 18:17:51 2015 UTC vs.
Revision 1.179 by dl, Sun Oct 4 11:33:47 2015 UTC

# Line 421 | Line 421 | public class CompletableFuture<T> implem
421      static final int ASYNC  =  1;
422      static final int NESTED = -1;
423  
424 +    /**
425 +     * Spins before blocking in waitingGet
426 +     */
427 +    static final int SPINS = (Runtime.getRuntime().availableProcessors() > 1 ?
428 +                              1 << 8 : 0);
429 +
430      /* ------------- Base Completion classes and operations -------------- */
431  
432      @SuppressWarnings("serial")
# Line 1724 | Line 1730 | public class CompletableFuture<T> implem
1730      private Object waitingGet(boolean interruptible) {
1731          Signaller q = null;
1732          boolean queued = false;
1733 <        int spins = -1;
1733 >        int spins = SPINS;
1734          Object r;
1735          while ((r = result) == null) {
1736 <            if (spins < 0)
1731 <                spins = (Runtime.getRuntime().availableProcessors() > 1) ?
1732 <                    1 << 8 : 0; // Use brief spin-wait on multiprocessors
1733 <            else if (spins > 0) {
1736 >            if (spins > 0) {
1737                  if (ThreadLocalRandom.nextSecondarySeed() >= 0)
1738                      --spins;
1739              }
# Line 1741 | Line 1744 | public class CompletableFuture<T> implem
1744              else {
1745                  try {
1746                      ForkJoinPool.managedBlock(q);
1747 <                } catch (InterruptedException ie) {
1747 >                } catch (InterruptedException ie) { // currently cannot happen
1748                      q.interrupted = true;
1749                  }
1750                  if (q.interrupted && interruptible)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines