Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yifei Zhang authored and jabolina committed Oct 24, 2024
1 parent cc47a30 commit a85bc98
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,20 +171,18 @@ private int index(Address addr) {
}

private void park(int ms) {
long deadline = System.nanoTime() + ms * 1000_000L;
long deadline = System.currentTimeMillis() + ms;
do {
LockSupport.parkUntil(deadline);
} while (System.nanoTime() < deadline);
} while (System.currentTimeMillis() < deadline);
}

void waitUntilPreVoteThreadStops(long timeout, int... indexes) {
ELECTION2[] a = stream(indexes).mapToObj(this::channel).filter(Objects::nonNull).map(this::election)
.filter(t -> t instanceof ELECTION2).toArray(ELECTION2[]::new);
if (a.length == 0) return;
eventually(() -> {
for (ELECTION2 e : a) {
if (e.isPreVoteThreadRunning()) return false;
}
for (ELECTION2 e : a) if (e.isPreVoteThreadRunning()) return false;
return true;
}, timeout, TimeUnit.MILLISECONDS);
}
Expand Down

0 comments on commit a85bc98

Please sign in to comment.