Skip to content

Commit

Permalink
Properly reset the phaser
Browse files Browse the repository at this point in the history
  • Loading branch information
heshanpadmasiri committed Dec 17, 2024
1 parent 534f7b4 commit ab2a1b5
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public final class Env {
private static final int TYPE_RESOLUTION_MAX_PERMITS = 10000;
private final Semaphore typeResolutionSemaphore = new Semaphore(TYPE_RESOLUTION_MAX_PERMITS);

private final Phaser typeResolutionPhaser = new Phaser();
private volatile Phaser typeResolutionPhaser = new Phaser();

private static final Env INSTANCE = new Env();

Expand Down Expand Up @@ -318,6 +318,13 @@ public Optional<AtomicType> atomicTypeByIndex(int index) {
void enterTypeResolutionPhase(Context cx, MutableSemType t) throws InterruptedException {
assert typeResolutionSemaphore.availablePermits() >= 0;
typeResolutionSemaphore.acquire();
if (typeResolutionPhaser.isTerminated()) {
synchronized (this) {
if (typeResolutionPhaser.isTerminated()) {
typeResolutionPhaser = new Phaser();
}
}
}
typeResolutionPhaser.register();
this.selfDiagnosticsRunner.registerTypeResolutionStart(cx, t);
}
Expand Down

0 comments on commit ab2a1b5

Please sign in to comment.