src/Pure/ML-Systems/multithreading_polyml.ML
changeset 31630 2f8ed0dca3bd
parent 31311 b82e55f51dcc
child 31897 15d55d07de8b
     1.1 --- a/src/Pure/ML-Systems/multithreading_polyml.ML	Sun Jun 14 09:13:59 2009 +0200
     1.2 +++ b/src/Pure/ML-Systems/multithreading_polyml.ML	Sun Jun 14 23:18:32 2009 +0200
     1.3 @@ -40,9 +40,16 @@
     1.4  
     1.5  val max_threads = ref 1;
     1.6  
     1.7 +val tested_platform =
     1.8 +  let val ml_platform = getenv "ML_PLATFORM"
     1.9 +  in String.isSuffix "linux" ml_platform orelse String.isSuffix "darwin" ml_platform end;
    1.10 +
    1.11  fun max_threads_value () =
    1.12 -  let val m = ! max_threads
    1.13 -  in if m <= 0 then Int.max (Thread.numProcessors (), 1) else m end;
    1.14 +  let val m = ! max_threads in
    1.15 +    if m > 0 then m
    1.16 +    else if not tested_platform then 1
    1.17 +    else Int.min (Int.max (Thread.numProcessors (), 1), 8)
    1.18 +  end;
    1.19  
    1.20  fun enabled () = max_threads_value () > 1;
    1.21