src/Pure/ML-Systems/multithreading_polyml.ML
changeset 31630 2f8ed0dca3bd
parent 31311 b82e55f51dcc
child 31897 15d55d07de8b
--- a/src/Pure/ML-Systems/multithreading_polyml.ML	Sun Jun 14 09:13:59 2009 +0200
+++ b/src/Pure/ML-Systems/multithreading_polyml.ML	Sun Jun 14 23:18:32 2009 +0200
@@ -40,9 +40,16 @@
 
 val max_threads = ref 1;
 
+val tested_platform =
+  let val ml_platform = getenv "ML_PLATFORM"
+  in String.isSuffix "linux" ml_platform orelse String.isSuffix "darwin" ml_platform end;
+
 fun max_threads_value () =
-  let val m = ! max_threads
-  in if m <= 0 then Int.max (Thread.numProcessors (), 1) else m end;
+  let val m = ! max_threads in
+    if m > 0 then m
+    else if not tested_platform then 1
+    else Int.min (Int.max (Thread.numProcessors (), 1), 8)
+  end;
 
 fun enabled () = max_threads_value () > 1;