@@ -57,19 +57,19 @@ private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter:
57
57
58
58
def createExecutorService : ExecutorService = {
59
59
60
- def getInt (name : String , f : String => Int ): Int =
61
- try f(System .getProperty(name)) catch { case e : Exception => Runtime .getRuntime.availableProcessors }
62
- def range (floor : Int , desired : Int , ceiling : Int ): Int =
63
- if (ceiling < floor) range(ceiling, desired, floor) else scala.math.min(scala.math.max(desired, floor), ceiling)
60
+ def getInt (name : String , default : String ) = (try System .getProperty(name, default) catch {
61
+ case e : SecurityException => default
62
+ }) match {
63
+ case s if s.charAt(0 ) == 'x' => (Runtime .getRuntime.availableProcessors * s.substring(1 ).toDouble).ceil.toInt
64
+ case other => other.toInt
65
+ }
66
+
67
+ def range (floor : Int , desired : Int , ceiling : Int ) = scala.math.min(scala.math.max(floor, desired), ceiling)
64
68
65
69
val desiredParallelism = range(
66
- getInt(" scala.concurrent.context.minThreads" , _.toInt),
67
- getInt(" scala.concurrent.context.numThreads" , {
68
- case null | " " => Runtime .getRuntime.availableProcessors
69
- case s if s.charAt(0 ) == 'x' => (Runtime .getRuntime.availableProcessors * s.substring(1 ).toDouble).ceil.toInt
70
- case other => other.toInt
71
- }),
72
- getInt(" scala.concurrent.context.maxThreads" , _.toInt))
70
+ getInt(" scala.concurrent.context.minThreads" , " 1" ),
71
+ getInt(" scala.concurrent.context.numThreads" , " x1" ),
72
+ getInt(" scala.concurrent.context.maxThreads" , " x1" ))
73
73
74
74
val threadFactory = new DefaultThreadFactory (daemonic = true )
75
75
0 commit comments