Skip to content

8353659: SubmissionPublisherTest::testCap1Submit times out #24473

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1278,8 +1278,7 @@ final int queueSize() {
* @param internal if caller owns this queue
* @throws RejectedExecutionException if array could not be resized
*/
final void push(ForkJoinTask<?> task, ForkJoinPool pool,
boolean internal) {
final void push(ForkJoinTask<?> task, ForkJoinPool pool, boolean internal) {
int s = top, b = base, m, cap, room; ForkJoinTask<?>[] a;
if ((a = array) != null && (cap = a.length) > 0 && // else disabled
task != null) {
Expand Down Expand Up @@ -1383,8 +1382,7 @@ final boolean tryUnpush(ForkJoinTask<?> task, boolean internal) {
if (a != null && (cap = a.length) > 0 &&
U.getReference(a, k = slotOffset((cap - 1) & s)) == task &&
(internal || tryLockPhase())) {
if (top == p &&
U.compareAndSetReference(a, k, task, null)) {
if (top == p && U.compareAndSetReference(a, k, task, null)) {
taken = true;
updateTop(s);
}
Expand Down Expand Up @@ -2061,8 +2059,9 @@ private int deactivate(WorkQueue w, int phase) {
((e & SHUTDOWN) != 0L && ac == 0 && quiescent() > 0) ||
(qs = queues) == null || (n = qs.length) <= 0)
return IDLE; // terminating
int k = Math.max(n << 2, SPIN_WAITS << 1);
for (int prechecks = k / n;;) { // reactivation threshold

for (int prechecks = Math.min(ac, 2), // reactivation threshold
k = Math.max(n + (n << 1), SPIN_WAITS << 1);;) {
WorkQueue q; int cap; ForkJoinTask<?>[] a; long c;
if (w.phase == activePhase)
return activePhase;
Expand All @@ -2071,7 +2070,7 @@ private int deactivate(WorkQueue w, int phase) {
if ((q = qs[k & (n - 1)]) == null)
Thread.onSpinWait();
else if ((a = q.array) != null && (cap = a.length) > 0 &&
a[q.base & (cap - 1)] != null && --prechecks <= 0 &&
a[q.base & (cap - 1)] != null && --prechecks < 0 &&
(int)(c = ctl) == activePhase &&
compareAndSetCtl(c, (sp & LMASK) | ((c + RC_UNIT) & UMASK)))
return w.phase = activePhase; // reactivate
Expand Down
7 changes: 3 additions & 4 deletions test/jdk/java/util/concurrent/tck/ForkJoinPool20Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ public void testScheduleWithFixedDelay_overflow() throws Exception {
final CountDownLatch delayedDone = new CountDownLatch(1);
final CountDownLatch immediateDone = new CountDownLatch(1);
final ForkJoinPool p = new ForkJoinPool(2);
p.cancelDelayedTasksOnShutdown();
try (PoolCleaner cleaner = cleaner(p)) {
final Runnable delayed = () -> {
delayedDone.countDown();
Expand Down Expand Up @@ -568,8 +569,8 @@ public void testSubmitWithTimeoutCancels() throws InterruptedException {
public Boolean call() throws Exception {
Thread.sleep(LONGER_DELAY_MS); return Boolean.TRUE; }};
ForkJoinTask<?> task = p.submitWithTimeout(c, 1, NANOSECONDS, null);
Thread.sleep(timeoutMillis());
assertTrue(task.isCancelled());
while(!task.isCancelled())
Thread.sleep(timeoutMillis());
}

static final class SubmitWithTimeoutException extends RuntimeException {}
Expand All @@ -586,7 +587,6 @@ public Item call() throws Exception {
c, 1, NANOSECONDS,
(ForkJoinTask<Item> t) ->
t.complete(two));
Thread.sleep(timeoutMillis());
assertEquals(task.join(), two);
}

Expand All @@ -602,7 +602,6 @@ public Boolean call() throws Exception {
c, 1, NANOSECONDS,
(ForkJoinTask<Boolean> t) ->
t.completeExceptionally(new SubmitWithTimeoutException()));
Thread.sleep(timeoutMillis());
try {
task.join();
shouldThrow();
Expand Down