subject to Multithreading.enabled;
authorwenzelm
Thu, 09 Oct 2008 20:53:16 +0200
changeset 28549 78affc7d4d0f
parent 28548 003f52c2bb8f
child 28550 422e9bd169ac
subject to Multithreading.enabled; raw_map: join sequentially, less overhead;
src/Pure/Concurrent/par_list.ML
--- a/src/Pure/Concurrent/par_list.ML	Thu Oct 09 20:53:15 2008 +0200
+++ b/src/Pure/Concurrent/par_list.ML	Thu Oct 09 20:53:16 2008 +0200
@@ -28,9 +28,13 @@
 struct
 
 fun raw_map f xs =
-  let val group = TaskQueue.new_group () in
-    Future.join_results (List.map (fn x => Future.future (SOME group) [] true (fn () => f x)) xs)
-  end;
+  if ! future_scheduler andalso Multithreading.enabled () then
+    let
+      val group = TaskQueue.new_group ();
+      val futures = map (fn x => Future.future (SOME group) [] true (fn () => f x)) xs;
+      val _ = List.app (ignore o Future.join_results o single) futures;
+    in Future.join_results futures end
+  else map (Exn.capture f) xs;
 
 fun map f xs = Exn.release_first (raw_map f xs);