Skip to content

Commit

Permalink
Wait longer in Selector
Browse files Browse the repository at this point in the history
  • Loading branch information
pron committed May 2, 2016
1 parent ac1e46b commit 98ee54b
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* Quasar: lightweight strands and actors for the JVM.
* Copyright (c) 2013-2014, Parallel Universe Software Co. All rights reserved.
*
Expand Down Expand Up @@ -454,13 +454,19 @@ boolean lease() {
record("lease", "trying lease %s", this);
Object w;
int i = 0;
long start = 0;
do {
w = winner;
if (w != null & w != LEASED)
return false;
if (i++ > 1 << 22) {
// System.err.println(Arrays.toString(st));
throw new RuntimeException("Unable to obtain selector lease: " + w);

if (i++ > (1 << 22)) {
if (start == 0)
start = System.nanoTime();
else if (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - start) > 10000)
throw new RuntimeException("Unable to obtain selector lease in 10 seconds: " + w);
i = 0;
Thread.yield();
}
} while (!casWinner(null, LEASED));
// st = Thread.currentThread().getStackTrace();
Expand Down

0 comments on commit 98ee54b

Please # to comment.