aboutsummaryrefslogtreecommitdiffstats
path: root/vespajlib/src/main/java/com/yahoo/concurrent
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-25 13:12:13 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2022-02-25 13:12:13 +0100
commitd69aeb4ee39c352c87336e617f5d73c58b2faeb8 (patch)
treeece110670f6fbc5eb89ea443a63fce72e1dc0fee /vespajlib/src/main/java/com/yahoo/concurrent
parent1f48f1e0cb904906e18ec220b0a3b21f8676dd27 (diff)
- Use a utility method that recomputes a timeout if VESPA_TIMER_HZ deviates from the default of 1000hz.
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/concurrent')
-rw-r--r--vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java b/vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java
index ecaae5e6387..38e93db30b6 100644
--- a/vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java
+++ b/vespajlib/src/main/java/com/yahoo/concurrent/SystemTimer.java
@@ -32,8 +32,12 @@ public enum SystemTimer implements Timer {
return hz;
}
+ public static int adjustTimeoutByDetectedHz(int timeoutMS) {
+ return (timeoutMS * 1000)/ detectHz();
+ }
+
SystemTimer() {
- int napTime = 1000 / detectHz();
+ int napTime = adjustTimeoutByDetectedHz(1);
millis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
Thread thread = new Thread() {