changeset 1639:4bea04866e8e

Reduce timer threads Reviewed-by: jerboaa Review-thread: http://icedtea.classpath.org/pipermail/thermostat/2014-December/012265.html
author Omair Majid <omajid@redhat.com>
date Tue, 16 Dec 2014 12:01:20 -0500
parents 461cef9a84c4
children 9198df881601
files common/core/src/main/java/com/redhat/thermostat/common/internal/ApplicationServiceImpl.java
diffstat 1 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/common/core/src/main/java/com/redhat/thermostat/common/internal/ApplicationServiceImpl.java	Mon Dec 15 13:23:01 2014 +0100
+++ b/common/core/src/main/java/com/redhat/thermostat/common/internal/ApplicationServiceImpl.java	Tue Dec 16 12:01:20 2014 -0500
@@ -54,8 +54,13 @@
     // when used carelessly).
     private ExecutorService executor = Executors.newCachedThreadPool();
 
-    // TODO: this is hardcoded, should really go into the configuration file
-    private TimerFactory timers = new ThreadPoolTimerFactory(100);
+    private TimerFactory timers;
+
+    public ApplicationServiceImpl() {
+        // TODO merge with QueuedStorage's determine-number-of-threads implementation
+        int poolSize = Runtime.getRuntime().availableProcessors() * 2;
+        timers = new ThreadPoolTimerFactory(poolSize);
+    }
 
     @Override
     public ApplicationCache getApplicationCache() {