diff options
Diffstat (limited to 'src/actors')
-rw-r--r-- | src/actors/scala/actors/FJTaskRunnerGroup.java | 4 | ||||
-rw-r--r-- | src/actors/scala/actors/FJTaskScheduler2.scala | 19 | ||||
-rw-r--r-- | src/actors/scala/actors/Scheduler.scala | 4 |
3 files changed, 19 insertions, 8 deletions
diff --git a/src/actors/scala/actors/FJTaskRunnerGroup.java b/src/actors/scala/actors/FJTaskRunnerGroup.java index 6fd53d5f97..1120dd1f54 100644 --- a/src/actors/scala/actors/FJTaskRunnerGroup.java +++ b/src/actors/scala/actors/FJTaskRunnerGroup.java @@ -257,7 +257,9 @@ public class FJTaskRunnerGroup implements IFJTaskRunnerGroup { System.arraycopy(threads, 0, newar, 0, newsize-1); synchronized(this) { threads = newar; - threads[newsize-1] = new FJTaskRunner(this); + FJTaskRunner t = new FJTaskRunner(this); + threads[newsize-1] = t; + setActive(t); } return true; } diff --git a/src/actors/scala/actors/FJTaskScheduler2.scala b/src/actors/scala/actors/FJTaskScheduler2.scala index 8b99b83f7c..848eebe169 100644 --- a/src/actors/scala/actors/FJTaskScheduler2.scala +++ b/src/actors/scala/actors/FJTaskScheduler2.scala @@ -12,7 +12,7 @@ package scala.actors import compat.Platform -import java.lang.{Runnable, Thread, InterruptedException, System} +import java.lang.{Runnable, Thread, InterruptedException, System, Runtime} import scala.collection.Set import scala.collection.mutable.{ArrayBuffer, Buffer, HashMap, Queue, Stack, HashSet} @@ -20,15 +20,17 @@ import scala.collection.mutable.{ArrayBuffer, Buffer, HashMap, Queue, Stack, Has /** * FJTaskScheduler2 * - * @version 0.9.10 + * @version 0.9.11 * @author Philipp Haller */ class FJTaskScheduler2 extends Thread with IScheduler { // as long as this thread runs, JVM should not exit setDaemon(false) - val printStats = false - //val printStats = true + var printStats = false + + val rt = Runtime.getRuntime() + val minNumThreads = 4 val coreProp = try { System.getProperty("actors.corePoolSize") @@ -46,7 +48,13 @@ class FJTaskScheduler2 extends Thread with IScheduler { val initCoreSize = if (null ne coreProp) Integer.parseInt(coreProp) - else 4 + else { + val numCores = rt.availableProcessors() + if (2 * numCores > minNumThreads) + 2 * numCores + else + minNumThreads + } val maxSize = if (null ne maxProp) Integer.parseInt(maxProp) @@ -114,6 +122,7 @@ class FJTaskScheduler2 extends Thread with IScheduler { if (Platform.currentTime - lastActivity >= TICK_FREQ && coreSize < maxSize && executor.checkPoolSize()) { + //Debug.info(this+": increasing thread pool size") coreSize += 1 lastActivity = Platform.currentTime } diff --git a/src/actors/scala/actors/Scheduler.scala b/src/actors/scala/actors/Scheduler.scala index cb10795899..73d40bea48 100644 --- a/src/actors/scala/actors/Scheduler.scala +++ b/src/actors/scala/actors/Scheduler.scala @@ -39,8 +39,8 @@ object Scheduler { sched.start() } - var tasks: LinkedQueue = null - var pendingCount = 0 + private var tasks: LinkedQueue = null + private var pendingCount = 0 def snapshot(): Unit = synchronized { tasks = sched.snapshot() |