From f29d1d172b82a3481f665999669daed74455ae55 Mon Sep 17 00:00:00 2001
From: Doug Lea
Date: Fri, 1 Nov 2019 09:07:59 -0700
Subject: [PATCH] 8231026: Miscellaneous changes imported from jsr166 CVS
2019-11
Reviewed-by: martin
---
.../util/concurrent/CompletableFuture.java | 119 ++++++-----
.../util/concurrent/tck/StampedLockTest.java | 185 ++++++++++++++----
2 files changed, 203 insertions(+), 101 deletions(-)
diff --git a/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java b/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java
index d83528f2fe7..2e704af9b95 100644
--- a/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java
+++ b/src/java.base/share/classes/java/util/concurrent/CompletableFuture.java
@@ -623,8 +623,8 @@ public class CompletableFuture implements Future, CompletionStage {
final CompletableFuture tryFire(int mode) {
CompletableFuture d; CompletableFuture a;
Object r; Throwable x; Function super T,? extends V> f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null)
+ if ((a = src) == null || (r = a.result) == null
+ || (d = dep) == null || (f = fn) == null)
return null;
tryComplete: if (d.result == null) {
if (r instanceof AltResult) {
@@ -645,7 +645,7 @@ public class CompletableFuture implements Future, CompletionStage {
d.completeThrowable(ex);
}
}
- dep = null; src = null; fn = null;
+ src = null; dep = null; fn = null;
return d.postFire(a, mode);
}
}
@@ -695,8 +695,8 @@ public class CompletableFuture implements Future, CompletionStage {
final CompletableFuture tryFire(int mode) {
CompletableFuture d; CompletableFuture a;
Object r; Throwable x; Consumer super T> f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null)
+ if ((a = src) == null || (r = a.result) == null
+ || (d = dep) == null || (f = fn) == null)
return null;
tryComplete: if (d.result == null) {
if (r instanceof AltResult) {
@@ -718,7 +718,7 @@ public class CompletableFuture implements Future, CompletionStage {
d.completeThrowable(ex);
}
}
- dep = null; src = null; fn = null;
+ src = null; dep = null; fn = null;
return d.postFire(a, mode);
}
}
@@ -769,8 +769,8 @@ public class CompletableFuture implements Future, CompletionStage {
final CompletableFuture tryFire(int mode) {
CompletableFuture d; CompletableFuture a;
Object r; Throwable x; Runnable f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null)
+ if ((a = src) == null || (r = a.result) == null
+ || (d = dep) == null || (f = fn) == null)
return null;
if (d.result == null) {
if (r instanceof AltResult && (x = ((AltResult)r).ex) != null)
@@ -787,7 +787,7 @@ public class CompletableFuture implements Future, CompletionStage {
d.completeThrowable(ex);
}
}
- dep = null; src = null; fn = null;
+ src = null; dep = null; fn = null;
return d.postFire(a, mode);
}
}
@@ -832,11 +832,11 @@ public class CompletableFuture implements Future, CompletionStage {
final CompletableFuture tryFire(int mode) {
CompletableFuture d; CompletableFuture a;
Object r; BiConsumer super T, ? super Throwable> f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null
+ if ((a = src) == null || (r = a.result) == null
+ || (d = dep) == null || (f = fn) == null
|| !d.uniWhenComplete(r, f, mode > 0 ? null : this))
return null;
- dep = null; src = null; fn = null;
+ src = null; dep = null; fn = null;
return d.postFire(a, mode);
}
}
@@ -902,11 +902,11 @@ public class CompletableFuture implements Future, CompletionStage {
final CompletableFuture tryFire(int mode) {
CompletableFuture d; CompletableFuture a;
Object r; BiFunction super T, Throwable, ? extends V> f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null
+ if ((a = src) == null || (r = a.result) == null
+ || (d = dep) == null || (f = fn) == null
|| !d.uniHandle(r, f, mode > 0 ? null : this))
return null;
- dep = null; src = null; fn = null;
+ src = null; dep = null; fn = null;
return d.postFire(a, mode);
}
}
@@ -965,11 +965,11 @@ public class CompletableFuture implements Future, CompletionStage {
final CompletableFuture tryFire(int mode) {
CompletableFuture d; CompletableFuture a;
Object r; Function super Throwable, ? extends T> f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null
+ if ((a = src) == null || (r = a.result) == null
+ || (d = dep) == null || (f = fn) == null
|| !d.uniExceptionally(r, f, mode > 0 ? null : this))
return null;
- dep = null; src = null; fn = null;
+ src = null; dep = null; fn = null;
return d.postFire(a, mode);
}
}
@@ -1024,8 +1024,8 @@ public class CompletableFuture implements Future, CompletionStage {
CompletableFuture d; CompletableFuture a;
Function> f;
Object r; Throwable x;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null)
+ if ((a = src) == null || (r = a.result) == null
+ || (d = dep) == null || (f = fn) == null)
return null;
if (d.result == null) {
if ((r instanceof AltResult) &&
@@ -1048,7 +1048,7 @@ public class CompletableFuture implements Future, CompletionStage {
else
d.internalComplete(r);
}
- dep = null; src = null; fn = null;
+ src = null; dep = null; fn = null;
return d.postFire(a, mode);
}
}
@@ -1086,8 +1086,8 @@ public class CompletableFuture implements Future, CompletionStage {
}
final CompletableFuture tryFire(int mode) {
CompletableFuture d; CompletableFuture a; Object r;
- if ((d = dep) == null
- || (a = src) == null || (r = a.result) == null)
+ if ((a = src) == null || (r = a.result) == null
+ || (d = dep) == null)
return null;
if (d.result == null)
d.completeRelay(r);
@@ -1128,8 +1128,8 @@ public class CompletableFuture implements Future, CompletionStage {
CompletableFuture d; CompletableFuture a;
Function super T, ? extends CompletionStage> f;
Object r; Throwable x;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null)
+ if ((a = src) == null || (r = a.result) == null
+ || (d = dep) == null || (f = fn) == null)
return null;
tryComplete: if (d.result == null) {
if (r instanceof AltResult) {
@@ -1155,7 +1155,7 @@ public class CompletableFuture implements Future, CompletionStage {
d.completeThrowable(ex);
}
}
- dep = null; src = null; fn = null;
+ src = null; dep = null; fn = null;
return d.postFire(a, mode);
}
}
@@ -1270,12 +1270,12 @@ public class CompletableFuture implements Future, CompletionStage {
CompletableFuture a;
CompletableFuture b;
Object r, s; BiFunction super T,? super U,? extends V> f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null
+ if ( (a = src) == null || (r = a.result) == null
|| (b = snd) == null || (s = b.result) == null
+ || (d = dep) == null || (f = fn) == null
|| !d.biApply(r, s, f, mode > 0 ? null : this))
return null;
- dep = null; src = null; snd = null; fn = null;
+ src = null; snd = null; dep = null; fn = null;
return d.postFire(a, b, mode);
}
}
@@ -1345,12 +1345,12 @@ public class CompletableFuture implements Future, CompletionStage {
CompletableFuture a;
CompletableFuture b;
Object r, s; BiConsumer super T,? super U> f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null
+ if ( (a = src) == null || (r = a.result) == null
|| (b = snd) == null || (s = b.result) == null
+ || (d = dep) == null || (f = fn) == null
|| !d.biAccept(r, s, f, mode > 0 ? null : this))
return null;
- dep = null; src = null; snd = null; fn = null;
+ src = null; snd = null; dep = null; fn = null;
return d.postFire(a, b, mode);
}
}
@@ -1421,12 +1421,12 @@ public class CompletableFuture implements Future, CompletionStage {
CompletableFuture a;
CompletableFuture b;
Object r, s; Runnable f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (r = a.result) == null
+ if ( (a = src) == null || (r = a.result) == null
|| (b = snd) == null || (s = b.result) == null
+ || (d = dep) == null || (f = fn) == null
|| !d.biRun(r, s, f, mode > 0 ? null : this))
return null;
- dep = null; src = null; snd = null; fn = null;
+ src = null; snd = null; dep = null; fn = null;
return d.postFire(a, b, mode);
}
}
@@ -1482,9 +1482,9 @@ public class CompletableFuture implements Future, CompletionStage {
CompletableFuture a;
CompletableFuture b;
Object r, s, z; Throwable x;
- if ((d = dep) == null
- || (a = src) == null || (r = a.result) == null
- || (b = snd) == null || (s = b.result) == null)
+ if ( (a = src) == null || (r = a.result) == null
+ || (b = snd) == null || (s = b.result) == null
+ || (d = dep) == null)
return null;
if (d.result == null) {
if ((r instanceof AltResult
@@ -1557,13 +1557,11 @@ public class CompletableFuture implements Future, CompletionStage {
super(executor, dep, src, snd); this.fn = fn;
}
final CompletableFuture tryFire(int mode) {
- CompletableFuture d;
- CompletableFuture a;
- CompletableFuture b;
+ CompletableFuture d; CompletableFuture extends T> a, b;
Object r; Throwable x; Function super T,? extends V> f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (b = snd) == null
- || ((r = a.result) == null && (r = b.result) == null))
+ if ((a = src) == null || (b = snd) == null
+ || ((r = a.result) == null && (r = b.result) == null)
+ || (d = dep) == null || (f = fn) == null)
return null;
tryComplete: if (d.result == null) {
try {
@@ -1582,7 +1580,7 @@ public class CompletableFuture implements Future, CompletionStage {
d.completeThrowable(ex);
}
}
- dep = null; src = null; snd = null; fn = null;
+ src = null; snd = null; dep = null; fn = null;
return d.postFire(a, b, mode);
}
}
@@ -1612,13 +1610,11 @@ public class CompletableFuture implements Future, CompletionStage {
super(executor, dep, src, snd); this.fn = fn;
}
final CompletableFuture tryFire(int mode) {
- CompletableFuture d;
- CompletableFuture a;
- CompletableFuture b;
+ CompletableFuture d; CompletableFuture extends T> a, b;
Object r; Throwable x; Consumer super T> f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (b = snd) == null
- || ((r = a.result) == null && (r = b.result) == null))
+ if ((a = src) == null || (b = snd) == null
+ || ((r = a.result) == null && (r = b.result) == null)
+ || (d = dep) == null || (f = fn) == null)
return null;
tryComplete: if (d.result == null) {
try {
@@ -1638,7 +1634,7 @@ public class CompletableFuture implements Future, CompletionStage {
d.completeThrowable(ex);
}
}
- dep = null; src = null; snd = null; fn = null;
+ src = null; snd = null; dep = null; fn = null;
return d.postFire(a, b, mode);
}
}
@@ -1668,13 +1664,11 @@ public class CompletableFuture implements Future, CompletionStage {
super(executor, dep, src, snd); this.fn = fn;
}
final CompletableFuture tryFire(int mode) {
- CompletableFuture d;
- CompletableFuture a;
- CompletableFuture b;
+ CompletableFuture d; CompletableFuture> a, b;
Object r; Throwable x; Runnable f;
- if ((d = dep) == null || (f = fn) == null
- || (a = src) == null || (b = snd) == null
- || ((r = a.result) == null && (r = b.result) == null))
+ if ((a = src) == null || (b = snd) == null
+ || ((r = a.result) == null && (r = b.result) == null)
+ || (d = dep) == null || (f = fn) == null)
return null;
if (d.result == null) {
try {
@@ -1691,7 +1685,7 @@ public class CompletableFuture implements Future, CompletionStage {
d.completeThrowable(ex);
}
}
- dep = null; src = null; snd = null; fn = null;
+ src = null; snd = null; dep = null; fn = null;
return d.postFire(a, b, mode);
}
}
@@ -1726,11 +1720,10 @@ public class CompletableFuture implements Future, CompletionStage {
CompletableFuture