From 98ee54b733250517bf49f840baba1b82b4a06cb2 Mon Sep 17 00:00:00 2001 From: pron Date: Mon, 2 May 2016 12:26:06 +0300 Subject: [PATCH] Wait longer in Selector --- .../strands/channels/Selector.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/quasar-core/src/main/java/co/paralleluniverse/strands/channels/Selector.java b/quasar-core/src/main/java/co/paralleluniverse/strands/channels/Selector.java index dcf15dc7ff..f31884f196 100644 --- a/quasar-core/src/main/java/co/paralleluniverse/strands/channels/Selector.java +++ b/quasar-core/src/main/java/co/paralleluniverse/strands/channels/Selector.java @@ -1,4 +1,4 @@ -/* + /* * Quasar: lightweight strands and actors for the JVM. * Copyright (c) 2013-2014, Parallel Universe Software Co. All rights reserved. * @@ -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();