CRITICAL force
authorhaftmann
Tue, 06 Nov 2007 13:12:52 +0100
changeset 25310 2b928fb92f53
parent 25309 30142fd3babf
child 25311 aa750e3a581c
CRITICAL force
src/Pure/General/susp.ML
--- a/src/Pure/General/susp.ML	Tue Nov 06 13:12:50 2007 +0100
+++ b/src/Pure/General/susp.ML	Tue Nov 06 13:12:52 2007 +0100
@@ -2,8 +2,7 @@
     ID:         $Id$
     Author:     Sebastian Skalberg and Florian Haftmann, TU Muenchen
 
-Delayed evaluation. Supposed to be value oriented; may result in
-multiple evaluations in a multi-threaded environment!
+Delayed evaluation. Supposed to be value-oriented.
 *)
 
 signature SUSP =
@@ -30,13 +29,18 @@
 fun delay f = ref (Delay f);
 
 fun force susp =
-  (case ! susp of
-    Value v => v
-  | Delay f =>
-      let
-        val v = f ();
-        val _ = susp := Value v;
-      in v end);
+  let
+    fun forc () = case ! susp
+     of Value v => v
+      | Delay f =>
+          let
+            val v = f ();
+            val _ = susp := Value v;
+          in v end;
+  in case ! susp
+   of Value v => v
+    | Delay _ => NAMED_CRITICAL "sups" forc
+  end;
 
 fun peek susp =
   (case ! susp of