join_results: allow CRITICAL join of finished futures;
authorwenzelm
Tue, 21 Oct 2008 16:53:00 +0200
changeset 28647 8068cdc84e7e
parent 28646 3a8d75c935ce
child 28648 4889b48919a0
join_results: allow CRITICAL join of finished futures; added singleton join_result;
src/Pure/Concurrent/future.ML
--- a/src/Pure/Concurrent/future.ML	Tue Oct 21 16:52:59 2008 +0200
+++ b/src/Pure/Concurrent/future.ML	Tue Oct 21 16:53:00 2008 +0200
@@ -40,6 +40,7 @@
   val fork: (unit -> 'a) -> 'a T
   val fork_background: (unit -> 'a) -> 'a T
   val join_results: 'a T list -> 'a Exn.result list
+  val join_result: 'a T -> 'a Exn.result
   val join: 'a T -> 'a
   val focus: task list -> unit
   val interrupt_task: string -> unit
@@ -258,6 +259,7 @@
       let
         val _ = scheduler_check "join check";
         val _ = Multithreading.self_critical () andalso
+          exists (not o is_finished) xs andalso
           error "Cannot join future values within critical section";
 
         fun join_loop _ [] = ()
@@ -287,7 +289,8 @@
 
       in xs |> map (fn Future {result = ref (SOME res), ...} => res) end) ();
 
-fun join x = Exn.release (singleton join_results x);
+fun join_result x = singleton join_results x;
+fun join x = Exn.release (join_result x);
 
 
 (* misc operations *)