aboutsummaryrefslogtreecommitdiffstats
path: root/messagebus/src/main/java/com/yahoo/messagebus/Messenger.java
diff options
context:
space:
mode:
Diffstat (limited to 'messagebus/src/main/java/com/yahoo/messagebus/Messenger.java')
-rwxr-xr-xmessagebus/src/main/java/com/yahoo/messagebus/Messenger.java13
1 files changed, 10 insertions, 3 deletions
diff --git a/messagebus/src/main/java/com/yahoo/messagebus/Messenger.java b/messagebus/src/main/java/com/yahoo/messagebus/Messenger.java
index f2ebbbe76cb..871f53396b4 100755
--- a/messagebus/src/main/java/com/yahoo/messagebus/Messenger.java
+++ b/messagebus/src/main/java/com/yahoo/messagebus/Messenger.java
@@ -1,6 +1,9 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.messagebus;
+import com.yahoo.concurrent.SystemTimer;
+
+import java.time.Duration;
import java.util.logging.Level;
import java.util.ArrayDeque;
@@ -147,12 +150,17 @@ public class Messenger implements Runnable {
@Override
public void run() {
+ long timeoutMS = SystemTimer.adjustTimeoutByDetectedHz(Duration.ofMillis(100)).toMillis();
while (true) {
Task task = null;
synchronized (this) {
if (queue.isEmpty()) {
try {
- wait(10);
+ if (children.isEmpty()) {
+ wait();
+ } else {
+ wait(timeoutMS);
+ }
} catch (final InterruptedException e) {
continue;
}
@@ -173,8 +181,7 @@ public class Messenger implements Runnable {
try {
task.destroy();
} catch (final Exception e) {
- log.warning("An exception was thrown while destroying " + task.getClass().getName() + ": " +
- e.toString());
+ log.warning("An exception was thrown while destroying " + task.getClass().getName() + ": " + e);
log.warning("Someone, somewhere might have to wait indefinitely for something.");
}
}