summaryrefslogtreecommitdiff
path: root/src/actors
diff options
context:
space:
mode:
Diffstat (limited to 'src/actors')
-rw-r--r--src/actors/scala/actors/scheduler/ThreadPoolConfig.scala45
1 files changed, 15 insertions, 30 deletions
diff --git a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala b/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala
index c34cc83df6..c96dd6d8d3 100644
--- a/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala
+++ b/src/actors/scala/actors/scheduler/ThreadPoolConfig.scala
@@ -11,6 +11,8 @@
package scala.actors
package scheduler
+import util.Properties.{ javaVersion, javaVmVendor, isJavaAtLeast, propIsSetTo, propOrNone }
+
/**
* @author Erik Engbrecht
* @author Philipp Haller
@@ -19,15 +21,9 @@ object ThreadPoolConfig {
private val rt = Runtime.getRuntime()
private val minNumThreads = 4
- private def getIntegerProp(propName: String): Option[Int] = {
- try {
- val prop = System.getProperty(propName)
- Some(Integer.parseInt(prop))
- } catch {
- case se: SecurityException => None
- case nfe: NumberFormatException => None
- }
- }
+ private def getIntegerProp(propName: String): Option[Int] =
+ try propOrNone(propName) map (_.toInt)
+ catch { case _: SecurityException | _: NumberFormatException => None }
val corePoolSize = getIntegerProp("actors.corePoolSize") match {
case Some(i) if i > 0 => i
@@ -38,30 +34,19 @@ object ThreadPoolConfig {
}
val maxPoolSize = {
- val preMaxSize = getIntegerProp("actors.maxPoolSize") match {
- case Some(i) => i
- case _ => 256
- }
+ val preMaxSize = getIntegerProp("actors.maxPoolSize") getOrElse 256
if (preMaxSize >= corePoolSize) preMaxSize else corePoolSize
}
private[actors] def useForkJoin: Boolean =
- try {
- val fjProp = System.getProperty("actors.enableForkJoin")
- if (fjProp != null)
- fjProp.equals("true")
- else {
- val javaVersion = System.getProperty("java.version")
- val jvmVendor = System.getProperty("java.vm.vendor")
- Debug.info(this+": java.version = "+javaVersion)
- Debug.info(this+": java.vm.vendor = "+jvmVendor)
- (javaVersion.indexOf("1.6") != -1 ||
- javaVersion.indexOf("1.7") != -1) &&
- // on IBM J9 1.6 do not use ForkJoinPool
- (jvmVendor.indexOf("Sun") != -1)
- }
- } catch {
- case se: SecurityException => false
- }
+ try propIsSetTo("actors.enableForkJoin", "true") || {
+ Debug.info(this+": java.version = "+javaVersion)
+ Debug.info(this+": java.vm.vendor = "+javaVmVendor)
+ // on IBM J9 1.6 do not use ForkJoinPool
+ isJavaAtLeast(1.6) && (javaVmVendor contains "Sun")
+ }
+ catch {
+ case _: SecurityException => false
+ }
}